You can't specify target table for update in FROM clause
来源:互联网 发布:顶点软件(603383)股吧 编辑:程序博客网 时间:2024/05/19 08:38
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错误
- Python 针对Json中某个关键字段进行排序
- 初识django
- 左手程序员,右手作家:你必须会的Jupyter Notebook
- 罗布泊双鱼玉佩
- 解决android studio错误 --> Error:(1, 0) Plugin with id 'com.android.application' not found
- You can't specify target table for update in FROM clause
- what is Velocity
- Live555学习之(二)------- testOnDemandRTSPServer
- 时光如梭,白驹过隙
- 大话Session
- android 自定义View 滚动选择器PickerView
- Mac AndroidStudio-常用dos操作命令
- 反射_读取和删除文件
- ubuntu 安装自然语言处理库 gensim