MYSQL:You can’t specify target table for update in FROM clause 解决办法
来源:互联网 发布:数据挖掘最优算法 编辑:程序博客网 时间:2024/06/05 07:58
在 MYSQL 数据库操作中:会报出错误 You can’t specify target table for update in FROM clause。
这句错误的意思是:不能对该表进行 update 操作。
出错原因是,被update的目标表是通过select方法筛选出来的表。
如以下写法就会出错:
UPDATE e_table SET state = 1 WHERE id in(SELECT id FROM e_table WHERE id > 0)
括号内的结果是通过 select 方法筛选的 e_table 表,被更新的表也是 e_table 表。所以会报错
解决办法,就是 select 后通过 as 关键字。
UPDATE e_table SET state = 1 WHERE id in(SELECT id FROM (SELECT id FROM e_table WHERE id > 0) AS new_table)
通过 AS 关键字,把 SELECT 出来的数据命名为 new_table 这时候再对原数据表 e_table 进行更新,就能成功执行了。
1 0
- 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 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 'table name' for update in FROM clause
- 【MySQL】1093 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 - You can't specify target table 'dataproduct' for update in FROM clause
- MySQL报错“ you can't specify the target table for ‘update’ in from clause”
- mysql中You can't specify target table 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错误
- 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 1093 - You can't specify target table '' for update in FROM clause
- mysql中You can't specify target table for update in FROM clause错误
- vuejs学习系列-第一个小demo
- 海量数据的解决方案
- spring-IOC进阶
- Linux下安装tomcat搭建集群
- Matlab读取Excel数据
- MYSQL:You can’t specify target table for update in FROM clause 解决办法
- poj 2342 树形dp入门
- VMware克隆虚拟机
- 如何实现单向链表的首尾添加
- 记第一次使用git上传本地文件到github
- 【MySQL基础】视图
- Hough变换理解
- kmp算法浅析
- 高效epoll原理