You can't specify target table 'test' for update in FROM clause.
2017-07-19 00:00
375 查看
You can't specify target table 'test' for update in FROM clause.
MySQL中You can't specify target table <test> for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)。 例如下面这个sql:
update test set `status`=3 where id in(select * from test where status=-50);
改写成下面就行了:
update test set `status`=3 where id in(select a.id from (select * from test where status=-50) a);
也就是说将select出的结果再通过中间表select一遍,这样就规避了错误。注意,这个问题只出现于mysql,mssql和Oracle不会出现此问题。
MySQL中You can't specify target table <test> for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)。 例如下面这个sql:
update test set `status`=3 where id in(select * from test where status=-50);
改写成下面就行了:
update test set `status`=3 where id in(select a.id from (select * from test where status=-50) a);
也就是说将select出的结果再通过中间表select一遍,这样就规避了错误。注意,这个问题只出现于mysql,mssql和Oracle不会出现此问题。
相关文章推荐
- [Err] 1093 - You can't specify target table 'exam_arrange_list' for update in FROM clause
- You can't specify target table 'xxx' for update in FROM clause
- MySQL [Err] 1093 - You can't specify target table 'test' for update in FROM clause
- mysql update语句问题:You can't specify target table 'user' for update in FROM clause
- 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:You can’t specify target table ‘A’ for update in FROM clause
- mysql中You can’t specify target table for update in FROM clause错误解决方法
- You can't specify target table 'XXX' for update in FROM clause
- mysql Error Code: 1093. You can't specify target table 'base_extend' for update in FROM clause 0.001
- mysql中You can’t specify target table for update in FROM clause错误解决方法
- MySQL数据库update更新子查询[Err] 1093 - You can't specify target table 'text' for update in FROM clause
- mysql异常:You can't specify target table 'my' for update in FROM clause
- mysql中You can't specify target table for update in FROM clause错误
- You can't specify target table X for update in FROM clause
- MySQL 错误码: 1093 You can't specify target table 'jc_user' for update in FROM clause
- mysql中You can’t specify target table for update in FROM clause错误解决方法
- mysql中You can't specify target table for update in FROM clause错误
- [Err] 1093 - You can't specify target table 'table' for update in FROM clause处理
- mysql中You can't specify target table for update in FROM clause错误