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...
deletefrom tbl where idin(selectmax(id)from tbl a whereEXISTS(select1from tbl b where a.tac=b.tac group by tacHAVINGcount(1)>1)group by tac) 也就是说将select出的结果再通过中间表select一遍,这样就规避了错误。注意,这个问题只出现于mysql,mssql和Oracle不会出现此问题。 代码语言:javascript 代...
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’的错误。你可以根据你的具体情况选择最适合...
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子句中再加一层,使其成为临时表: ...
@文心快码mysql for update in from clause 文心快码 1. 解释什么是 "for update" 语句,并指出其在 MySQL 中的用途 "for update" 语句在 SQL 中用于对查询结果集中的行进行排他锁定,以防止其他事务对这些行进行修改或删除。在 MySQL 中,这通常用于事务处理中,以确保数据的一致性和完整性。当一条记录被锁定...
mysql You can't specify target table 'xxx' for update in FROM clause,含义:您不能在子句中为更新指定目标表'xxx'。错误描述:删除语句中直接含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 这个表(在同一语句中),即不能依据某字段值做判断再来更新某字段的值。
(等待mysql升级吧)错误提示就是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)替换方案create table tmp as select min(id) as col1 from blur_article group by titledelete from blur_article where id not in (select col1 from tmp)drop table tmp已经测试,尽请使用...