mysql中You can’t specify target table for update in FROM clause错误解决方法
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不会出现此问题。
http://www.jb51.net/article/60926.htm
mysql中You can’t specify target table for update in FROM clause错误解决方法的更多相关文章
- MySQL--mysql中You can’t specify target table for update in FROM clause错误解决方法
参考:http://www.jb51.net/article/60926.htm mysql中You can't specify target table for update in FROM cla ...
- MySQL 出现You can't specify target table for update in FROM clause错误解决方法
MySQL出现You can’t specify target table for update in FROM clause 这个错误的意思是不能在同一个sql语句中,先select同一个表的某些值 ...
- Mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)。
将select出的结果再通过中间表select一遍,这样就规避了错误.注意,这个问题只出现于mysql,mssql和oracle不会出现此问题. mysql中You can't specify tar ...
- mysql中You can't specify target table for update in FROM clause错误
原SQL delete from DEP_SYSTEM_PORTLET_SETTINGS where ID in ( select ID from DEP_SYSTEM_PORTLET_SETTING ...
- mysql 出现You can't specify target table for update in FROM clause错误的解决方法
mysql出现You can’t specify target table for update in FROM clause 这个错误的意思是不能在同一个sql语句中,先select同一个表的某些值 ...
- MySQL中You can't specify target table for update in FROM clause一场
mysql中You can't specify target table <tbl> for update in FROM clause错误的意思是说,不能先select出同一表中的某些值 ...
- mysql中You can't specify target table for update in FROM clause
使用mysql在删除表中重复记录 delete from user where username in (select user name form(select username from user ...
- MySQL中You can't specify target table for update in FROM clause异常
mysql中You can't specify target table <tbl> for update in FROM clause错误的意思是说,不能先select出同一表中的某些值 ...
- mysql错误:1093-You can’t specify target table for update in FROM clause的解决方法
update语句中包含的子查询的表和update的表为同一张表时,报错:1093-You can’t specify target table for update in FROM clause my ...
随机推荐
- Android(Xamarin)之旅(一)
Xamarin废话我就不多说了. 就是一款编写Android和IOS应用的IDE,从Visual Studio2010就开始有个这个插件.只要发展什么的,我觉得在这里说还不如自己去百度呢. 入正题: ...
- iOS 开发线程 gcd
基础知识: 下午9:09 一.基础概念 1.什么是GCD 全称是Grand Central Dispath 纯C语言编写,提供非常多且强大的函数,是目前推荐的多线程开发方法,NSOperation ...
- [VBS]带参数删除扩展名不是*.h、*.c、*.cpp的全部文件
脚本使用例程CleanFolder遍历一个文件夹 1)使用CleanFolder递归遍历该文件夹下的所有子文件夹 2)如果该子文件夹的大小为0,则删除这个文件夹 3)遍历该文件夹下的所有文件,扩展名不 ...
- berkeley db replica机制 - 主从同步
repmgr/repmgr_net.c, __repmgr_send(): 做send_broadcast, 然后根据policy 对DB_REP_PERMANENT的处理 __repmgr_send ...
- 关闭 selinux 和防火墙
1.关闭 selinux 修改 它的配置文档 /etc/selinux/conf 修改 SELINUX=disabled 或者permissive 2. 关闭 防火墙 输入命令 systemctl d ...
- 第一个Struts1步骤
一.前端 :登陆页面 index.jsp <%@ page language="java" import="java.util.*" pageEncodi ...
- hdu 5100 n*n棋盘放k*1长方条最多覆盖面积
http://acm.hdu.edu.cn/showproblem.php?pid=5100 给一个n*n的棋盘,问用k*1的长方条最多能覆盖多大的面积(k个单位都必须完全覆盖上去) 首先,若n< ...
- Webpack使用教程四(Loaders)
Loaders是webpack最有用的特性之一,通过Loaders,webpack可以预处理源码文件中的Json文件或者将包含新特性的Javascript代码转换成浏览器能处理的JavaScript代 ...
- LINQ to SQL大全
LINQ to SQL语句 (1)之Where Where操作 适用场景:实现过滤,查询等功能. 说明:与SQL命令中的Where作用相似,都是起到范围限定也就是过滤作用的,而判断条件就是它后面所接的 ...
- IIS7.5 HTTP错误403.1-Forbidden 您尝试从某个目录运行CGI、ISAPI或其他可执行程序,但该目录不允许运行可执行文件
----------------错误详细---------------------------------------------------------------- --------------- ...