MySQL can’t specify target table for update in FROM clause
翻译:MySQL不能指定更新的目标表在FROM子句
源SQL语句:
- delete from t_official_sys_user
- where USER_NAME IN(SELECT USER_NAME FROM t_official_sys_user b group by b.`USER_NAME` having count(1) > 1)
执行报以下错误:
- [SQL]
- delete from t_official_sys_user
- where USER_NAME IN(SELECT USER_NAME FROM t_official_sys_user b group by b.`USER_NAME` having count(1) > 1)
- [Err] 1093 - You can't specify target table 't_official_sys_user' for update in FROM clause
解决代码如下:
- delete from t_official_sys_user
- where USER_NAME IN(
- select USER_NAME from
- (
- SELECT USER_NAME FROM t_official_sys_user b group by b.`USER_NAME` having count(1) > 1
- ) as temtable
- );
分析:
先把要删除的目标放到一张临时表再把要删除的条件指定到这张临时表即可。
http://blog.csdn.net/bluestarf/article/details/46622455
http://www.cnblogs.com/nick-huang/p/4412818.html
MySQL 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错误的意思是说,不能先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 即:不能先select出同一表中的某些值,再update ...
- 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错误解决方法,需要的朋友可以参考下 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 这个错误的意思是不能在同一个sql语句中,先select同一个表的某些值 ...
- MYSQL 1093 之You can't specify target table for update in FROM clause解决办法
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错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...
- 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这个表( ...
- 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 ...
随机推荐
- c++Builder 下的文件及目录操作
转自 http://blog.csdn.net/ktcserver/article/details/936329 一.判断目录是否存在: C++ Builder中提供了检查文件 ...
- 三【相关度 相似度查询与计算】相似度到大数据查找之Mysql 文章匹配的一些思路与提高查询速度
记录下,在上2回的数据基础之上,附带一个互信息(MI,Mutual Information)可以计算词之间的相关度 标准互信息 MI(X,Y)=log2p(x,y)/p(x)p(y) 值越大于0 则趋 ...
- 03静态链表_StaticLinkList--(线性表)
#include "string.h" #include "ctype.h" #include "stdio.h" #include &qu ...
- [翻译][MVC 5 + EF 6] 8:更新相关数据
原文:Updating Related Data with the Entity Framework in an ASP.NET MVC Application 1.定制Course的Create和E ...
- JS中undefined和null的区别
在写JS脚本的时候,经常会碰到“为空”的判断,其中主要有null和undefined的判断.这两个为空判断的主要区别是: 1) null是JS的关键字,是语法特性.undefined是全局对象的属性, ...
- CentOS7 查看ip
查看内网:ip addr 查看公网:curl members.3322.org/dyndns/getip
- CentOS上无法识别NTFS格式分区的解决方法
插入U盘之后,按照下面的步骤: # fdisk -l /dev/sd* 通常这一步就能找到U盘,如果U盘有指示灯也会亮,表示被找到. # mount –t ntfs /dev/sdb1 /mnt/ ...
- Web前端新人笔记之CSS字体
本章内容是阅读CSS权威指南的一个小积累和随笔.新人必看,老鸟也可查看并指出不足指出以便后人阅读更好地理解.O(∩_∩)O谢谢!!!设置字体属性时样式变的最常见的用途之一:不过,尽管字体选择很重要,但 ...
- textarea限定字数提示效果
最近工作中要实现的一个效果是:在textarea中输入字符会提示剩余多少字符可输入.于是马不停蹄的开始查阅资料. HTML代码: <table> <colgroup> < ...
- sql 修改字段小记
增加字段默认值: alter table 表名 ADD 字段 类型 NULL Default 0 修改字段类型: alter table 表名 alter column UnitPrice decim ...