mysql异常:You can't specify target table 'my' for update in FROM clause
2017-08-06 11:39
375 查看
如果需要数据库中的数据与现有的数据进行操作
在mysql中,需要在查询原有数据时,需要将其作为中间表然后进行操作.
oracle则不需要
举例 :
表结构
![](https://img-blog.csdn.net/20170806113755417?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMzQ1MzE5MjU=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
如下是错误的
报错信息:
mysql正确方式
OK
在mysql中,需要在查询原有数据时,需要将其作为中间表然后进行操作.
oracle则不需要
举例 :
表结构
如下是错误的
INSERT INTO my (id, iden, NAME, age) VALUES ( 2, '2', '2', 1 + IFNULL( ( SELECT age FROM my WHERE id = 1 ), 0 ) );
报错信息:
[SQL]INSERT INTO my (id, iden, NAME, age) VALUES ( 2, '2', '2', 1 + IFNULL( ( SELECT age FROM my WHERE id = 1 ), 0 ) );
[Err] 1093 - You can't specify target table 'my' for update in FROM clause
mysql正确方式
INSERT INTO my (id, iden, NAME, age) VALUES ( 2, '2', '2', 1 + IFNULL( ( SELECT a.age FROM (SELECT age FROM my WHERE id = 1) a ), 0 ) );
OK
[SQL]INSERT INTO my (id,iden, NAME, age) VALUES ( 2, '2', '2', 1 + IFNULL( (SELECT a.age from (SELECT age FROM my WHERE id = 1) a), 0 ) ); 受影响的行: 1 时间: 0.007s
相关文章推荐
- 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 'image' for update in FROM clause
- MySQL 中 You can't specify target table '表名' for update in FROM clause错误解决办法
- You can't specify target table 'marketing_setting' for update in FROM clause
- [Err] 1093 - You can't specify target table 'matorder' for update in FROM clause 原句:delete from mat
- 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错误解决方法
- mysql 出现You can't specify target table for update in FROM clause错误的解决方法
- mysql中的一个特殊问题:You can’t specify target table ‘abc’ 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 Error Code: 1093. You can't specify target table 'base_extend' for update in FROM clause 0.001
- You can't specify target table 'XXX' for update in FROM clause
- [Err] 1093 - You can't specify target table 's' for update in FROM clause
- You can't specify target table for update in FROM clause
- You can't specify target table 'tableName' for update in FROM clause
- You can't specify target table for update in FROM clause
- MySQL [Err] 1093 - You can't specify target table 'test' for update in FROM clause
- [Err] 1093 - You can't specify target table 's' for update in FROM clause