mysql error: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不会出现此问题。
mysql error: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 这个错误的意思是不能在同一个sql语句中,先select同一个表的某些值 ...
- 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 for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...
- 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 c ...
- 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这个表( ...
- 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
使用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 for update in FROM clause UPDATE edu_grade_hgm_1 ' W ...
- 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出同一表中的某些值 ...
随机推荐
- 2014 蓝桥杯 预赛 c/c++ 本科B组 第九题:地宫取宝(12') [ dp ]
历届试题 地宫取宝 时间限制:1.0s 内存限制:256.0MB 锦囊1 锦囊2 锦囊3 问题描述 X 国王有一个地宫宝库.是 n x m 个格子的矩阵.每个格子放一件 ...
- python学习之-- redis模块操作 string
redis 模块操作之--> String String:redis中的string在内存中按照一个key 对应一个 value来存储. 使用方法如下:set(name, value, ex=N ...
- DTrace scripts for Mac OS X
http://www.cnblogs.com/Proteas/p/3727297.html http://dtrace.org/blogs/brendan/2011/10/10/top-10-dtra ...
- Meteor在手机上运行
在本章中,我们将学习如何在Android设备上运行你的应用程序.最近Meteor刚刚添加此功能适用于Windows操作系统,所以我们需要更新 Meteor 应用到 1.3测试版. 注 在写的时候本教程 ...
- vs2015编译zlib1.2.8
编译最新的libcurl 7.44.0时须要先编译下zlib 1.2.8遇到了点小麻烦 记录下 1.编译步骤 a.先用vs2015命令行运行下bld_ml32.bat批处理 b.将inffas32.o ...
- CentOS5 忘记root密码的解决办法
方法/步骤 1 开机启动的时候,按“E”进入如下界面. 2 选择相应的内核,再次按“E”,出现下图,选择第二项,再次按“E”键 3 在尾部加:“空格+single”(如图),Enter.图如下: ...
- cocos2d-x进化为2.5D的一些想法
首先我得说Unity3D已经做的非常好了,搞这些东西意义真心不大.详细Unity3D有什么优势我之前也写过两篇文章来阐述自己的想法. 假设我的下一份工作是U3D的话,预计我就不会 ...
- Deepin-安装(读写文件)权限
在安装NODE管理模块N时,遇到了权限问题 1.给予程序读写权限(仅限文件夹) 查看权限:ls -l 或 ls 添加权限: 示例:chmod +rw xx 实例:chmod +rw node 关于权限 ...
- js获取get传递的值
<script language="javascript" src="js/jquery-1.9.0.min.js"></script> ...
- var和dynamic的应用 var、动态类型 dynamic 深入浅析C#中的var和dynamic ----demo
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...