SQL update语句 更新和查询同一张表 冲突

#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)

原文地址:https://www.cnblogs.com/cyq632694540/p/8034340.html