mySQL: delete 语句报错 You can't specify target table 'student' for update in FROM clause 原因是子查询中使用student表进行查询,而外层的delete语句也是对student进行的操作,因此报错。 解决办法: 将子查询再包装一次: DELETEFROMstudentWHEREIDin(SELECT*FROM(SELECTIDFROMstudentwhere1=1and(student.name='X'...
当在mysql中执行这条语句时,报错:You can't specify target table 'student' for update in FROM clause; 原因是子查询中使用student表进行查询,而外层的delete语句也是对student进行的操作,因此报错。 解决办法: 将子查询再包装一次: deletefromstudentwhereidNOTin(select*from(selectmin(id) idfromstudentgroupbyn...
delete from student where id in (select id from student where name = '张三'); 1. 2. 3. 4. 5. 此时会提示:1093 - You can’t specify target table ‘student’ for update in FROM clause 解决方式:在where子句中再加一层,使其成为临时表: update student set address = '杭州' where id in...
UPDATE my_table AS t1 JOIN (SELECT my_value FROM my_table WHERE condition) AS t2 ON t1.some_condition = t2.some_condition SET t1.my_column = t2.my_value; 这些方法都可以解决’You can’t specify target table ‘xxx’ for update in FROM clause’的错误。你可以根据你的具体情况选择最适合...
MySQL中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)。 例如下面这个sql:
MySQL 中 You can't specify target table '表名' for update in FROM clause错误解决办法,在MySQL中,写SQL语句的时候,可能会遇到Youcan'tspecifytargettable'表名'forupdateinFROMclause这样的错误,它的意思是说,不能先select出同
简介:【MySQL异常】1093 - You can‘t specify target table ‘daily_job‘ for update in FROM clause 一、背景描述 通过sql语句想把这个表里的数据查询出来,然后根据查询出来的id把同一张表里的数据删除, 如下是会报错的sql语句: DELETEFROMdaily_jobWHEREid IN ( SELECT id FROM daily_job WHERE create_user...
在MySQL中,写SQL语句的时候 ,可能会遇到 You can't specify target table '表名' for update in FROM clause 这样的错误 错误含义 它的意思是说,不能先 select 出同一表中的某些值,再 update 这个表(在同一语句中),即不能依据某字段值做判断再来更新某字段的值。
optimizations. As a workaround, try rewriting them as multiple-table UPDATEand DELETEstatements that use a join rather than a subquery. 实际就是下面的执行计划: mysql> explain delete from testde1 where id in (select id from testde2); ...
1.使⽤mysql进⾏delete from操作时,若⼦查询的 FROM 字句和更新/删除对象使⽤同⼀张表,会出现错误。mysql> DELETE FROM tab1 WHERE col1 = ( SELECT MAX( col1 ) FROM tab1 );ERROR 1093 (HY000): You can’t specify target table ‘tab1′ for update in FROM clause 针对“同⼀张表”...