#update 和 select在同一张表的时候会显示冲突 报错信息: [Err] 1093 - You can't specify target table 'tb_a' for update in FROM clause
update tb_a set sex='boy' where uid =(select uid from tb_a where name ='cyq')
#解决方式:嵌套多一个查询表
update tb_a set sex='boy' where uid =(select uid from(select uid from tb_a where name ='cyq') as tb_tmp)
本文介绍了当在SQL中尝试在同一张表上同时执行UPDATE和SELECT操作时出现的错误[Err]1093,并提供了一种解决方案。通过在SELECT语句外增加一层子查询,可以有效避免该冲突。

被折叠的 条评论
为什么被折叠?



