MySQL执行更新语句报错:

更新语句:UPDATE test SET state=50 WHERE num IN(SELECT num FROM test WHERE state=60);

报错:ERROR 1093 (HY000): You can't specify target table 'test' for update in FROM clause

表数据:

state num
50 101
50 102
50 201
60 202
60 203

解决方式:同表不支持 update子查询结果,将子查询结果,再select一次,就可以了

改成:UPDATE test SET state=50 WHERE num IN(SELECT * FROM (SELECT num FROM test WHERE state=60));

ERROR 1093 (HY000): You can't specify target table 'test' for update in FROM clause的更多相关文章

  1. MySQL - 1093异常 - You can't specify target table 't' for update in FROM clause

    有一个表示地区的表,表结构与数据大概如下表. ID NAME PARENT_ID 1 中国 2 广东省 1 3 广州市 2 4 荔湾区 3 5 越秀区 3 6 番禺区 3 7 小谷围街道 6 现为了查 ...

  2. MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause

    MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause 201 ...

  3. Mysql update in报错 [Err] 1093 - You can't specify target table 'company_info' for update in FROM clause

    Mysql update in报错 解决方案: [Err] 1093 - You can't specify target table 'company_info' for update in FRO ...

  4. [Err] 1093 - You can't specify target table 's' for update in FROM clause

    [Err] 1093 - You can't specify target table 's' for update in FROM clause 执行SQL DELETE from book WHE ...

  5. 关于mysql 5.7版本“报[Err] 1093 - You can't specify target table 'XXX' for update in FROM clause”错误的bug

    不同于oracle和sqlserver,mysql并不支持在更新某个表的数据时又查询了它,而查询的数据又做了更新的条件,因此我们需要使用如下的语句绕过: , notice_code ) a) ; 本地 ...

  6. 1093 - You can't specify target table 'account' for update in FROM clause

    目的:查询一张表的相同的两条数据,并删除一条数据. 分析 先查询出相同的数据,然后删除 查询相同的数据 SELECT a.id FROM account a GROUP BY a.username H ...

  7. MySQL 1093 - You can't specify target table 'sc' for update in FROM clause

    错误代码如下: #(8) 把"邓维杰"同学的成绩全部删除. SELECT * FROM sc WHERE EXISTS(SELECT * FROM student WHERE st ...

  8. You can't specify target table 'ship_product_cat' for update in FROM clause

    有时候我们在编辑update时需要select作为条件,在mysql中有时会出现这样的错误:You can't specify target table for update in FROM clau ...

  9. 【SQL】 java.sql.SQLException: You can't specify target table 'emp' for update in FROM clause

    在执行sql: delete from emp where id in (select id from emp where cdate<'2018-02-02') 时报出以下异常: ### Th ...

随机推荐

  1. ionic 上拉加载问题(分页)

    问题描述: 1.第一初始化时执行了上拉加载更多. 2.上拉时存在执行多次加载动作. angularjs的ajax不提供同步机制,是为了防止页面长时间等待,很多时候我们又需要这种同步机制交换状态,比如上 ...

  2. 一百本英文原著之旅 ( 15 finished )

    记得去年毕业的时候,突然想看英文原著(小说.文学.技术 etc.)来提高自己的英文水平.并且那时候愣愣的有了个宏伟的目标 --> 一百本.  不过也就去年下半年断断续续的看了些页数在200左右的 ...

  3. R语言中的MySQL操作

    R语言中,针对MySQL数据库的操作执行其实也有很多中方式.本人觉得,熟练掌握一种便可,下面主要就个人的学习使用情况,总结其中一种情况-----使用RMySQL操作数据库. 1.下载DBI和RMySQ ...

  4. R中实现脚本调用,以及函数调用

    R中实现脚本调用,以及函数调用 这里的列子是test.R调用mysql_con.R中的函数 mysql_con.R # 使用RMySQL操作数据库 # 载入DBI和RMySQL包 #library(D ...

  5. 1044: Access denied for user 'hehe'@'localhost' to database 'imooc'

    当我使用 mysql授予用户时, GRANT ALL PRIVILEGES ON *.* TO hehe IDENTIFIED BY 'some' WITH GRANT OPTION; 出现:1044 ...

  6. (转)android mock location

    android mock location 2014-01-26     我来说两句   来源:党玉涛   收藏 我要投稿 现在软件市场上有很多可以改变手机地理位置的软件,更改后打开微信就可以随意定位 ...

  7. elasticsearch的store属性 vs _source字段

    众所周知_source字段存储的是索引的原始内容,那store属性的设置是为何呢?es为什么要把store的默认取值设置为no?设置为yes是否是重复的存储呢? 我们将一个field的值写入es中,要 ...

  8. WHICH ONE IS BETTER FOR NEWBIE?

    DROP PROCEDURE IF EXISTS w_array; DELIMITER /w/ )) BEGIN ) DO SET @w = LOCATE(',', w_arr); ); SET @w ...

  9. git远程库与本地联系报错:fatal: Not a git repository (or any of the parent directories): .git

    在github上新建了一个仓库,然后相与本地的仓库联系起来 $ git remote add origin https://github.com/lizhong24/mysite2.git fatal ...

  10. librosa音频特征提取,python librosa库在centos上依赖llvm的问题?

    win10下安装使用: https://blog.csdn.net/qq_39516859/article/details/80679718 https://blog.csdn.net/qq_3951 ...