You can't specify target table for update in FROM clause
来源:互联网 发布:淘宝关键词推广 编辑:程序博客网 时间:2024/06/03 06:41
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)。 例如下面这个sql:
代码如下:
delete from tbl where id in ( select max(id) from tbl a where EXISTS ( select 1 from tbl b where a.tac=b.tac group by tac HAVING count(1)>1 ) group by tac)
改写成下面就行了:
代码如下:
delete from tbl where id in ( select a.id from ( select max(id) id from tbl a where EXISTS ( select 1 from tbl b where a.tac=b.tac group by tac HAVING count(1)>1 ) group by tac ) a)
也就是说将select出的结果再通过中间表select一遍,这样就规避了错误。注意,这个问题只出现于mysql,mssql和oracle不会出现此问题。
阅读全文
0 0
- mysql update语句问题:You can't specify target table 'user' for update in FROM clause
- You can't specify target table 'table name' for update in FROM clause
- MySql报错: You can't specify target table 'table name' for update in FROM clause
- 【MySQL】1093 You can't specify target table 'table name' for update in FROM clause
- [Err] 1093 - You can't specify target table 'table' for update in FROM clause处理
- You can't specify target table 't' for update in FROM clause
- Mysql - You can't specify target table 'dataproduct' for update in FROM clause
- You can't specify target table 'wms_cabinet_form' for update in FROM clause
- MySQL报错“ you can't specify the target table for ‘update’ in from clause”
- You can't specify target table 'sc1' for update in FROM clause
- [Err] 1093 - You can't specify target table 's' for update in FROM clause
- mysql中You can't specify target table for update in FROM clause错误
- You can't specify target table 'sdb_goods' for update in FROM clause
- You can't specify target table 'A' for update in FROM clause
- MYSQL 临时表 #1093 - You can't specify target table 'dealer_admin' for update in FROM clause
- MySQL "You can't specify target table 'X' for update in FROM clause" 错误解决方法
- Mysql 错误 Code: 1093. You can't specify target table for update in FROM clause
- mysql中You can't specify target table for update in FROM clause错误
- 原型与原型链
- UICollectionView实现头部漂浮的效果
- Dialog各种样式
- Java中的equals和hashCode方法详解
- 关于Post请求的四种方式
- You can't specify target table for update in FROM clause
- Jmeter3.2版本发送SOAP请求测试webservice接口
- C++ 原子操作(6种原子顺序)
- OpenGL中关于帧缓冲区的理解
- vue-router的详细讲解
- 反素数深度分析【转载】
- js事件绑定
- 7-6 列出连通集(25 分)
- LoRa,物联网创新应用中的新宠!