MySQL 中 You can't specify target table '表名' for update in FROM clause错误解决办法

前端之家收集整理的这篇文章主要介绍了MySQL 中 You can't specify target table '表名' for update in FROM clause错误解决办法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

背景

MysqL中,写sql语句的时候 ,可能会遇到 You can't specify target table '表名 for update in FROM clause 这样的错误

错误含义

它的意思是说,不能先 select 出同一表中的某些值,再 update 这个表(在同一语句中),即不能依据某字段值做判断再来更新某字段的值。

 

解决问题

将select出的结果再通过中间表select一遍,这样就可以解决错误

@H_502_35@

 

猜你在找的MySQL相关文章