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错误解决方法的更多相关文章

  1. 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 ...

  2. 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同一个表的某些值 ...

  3. 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 ...

  4. 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 ...

  5. 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同一个表的某些值 ...

  6. 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出同一表中的某些值 ...

  7. 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 ...

  8. 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出同一表中的某些值 ...

  9. 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 ...

随机推荐

  1. Multi-line NSAttributedString with truncated text

    http://stackoverflow.com/questions/7611816/multi-line-nsattributedstring-with-truncated-text/1017279 ...

  2. oracle安装心得

    1.官网下载 oracle 11g r2 2.官网下载的oracle包括两个文件夹file1和file2,需要将解压后的file2中的stage-components文件夹下的内容复制到file1-s ...

  3. 4.“写程序” 这个活动大多数情况下是个人行为。 我们听说的优秀程序员似乎都是单打独斗地完成任务。同学们在大学里也认识一些参加ACM 比赛的编程牛人, 他们写的ACM 比赛的程序是软件么? “写程序” 和 ”做软件“ 有区别么? 请采访这些学生。

    ACM的题库的编程都只能算做程序,不能算软件.写程序和做软件区别还是很大的.程序是为实现特定目标或解决特定问题而用计算机语言编写的命令序列的集合.为实现预期目的而进行操作的一系列语句和指令.而软件是程 ...

  4. C语言误区

    int date[10] ; //定义一个字长10的数组,从date[0]....date[9] static   char   c ;   //静态变量(有静态外部变量和静态局部变量),静态外部变量 ...

  5. Git 常用几个操作

    获取 git clone git@github.com:XXX/learning.git 更新 git pull  添加 git add XXX 上传本地 git commit -m "ap ...

  6. "产品测试管理&敏捷项目管理"研讨会在深圳成功举办!

    2016年1月9日,由深圳市共创力企业管理咨询发起的"产品测试管理&敏捷项目管理"研讨会在深圳南山科技园创新谷咖啡成功举办!参加此次研讨会的企业有华为.中兴.烽火.腾讯.康 ...

  7. Selenium WebDriver使用IE浏览器

    摘:http://www.cnblogs.com/dream0577/archive/2012/10/07/2714579.html /**       用IE驱动,1.先到官网下载IEDriverS ...

  8. hdu 4648 - Magic Pen 6(“水”题)

    摘自题解: 题意转化一下就是: 给出一列数a[1]...a[n],求长度最长的一段连续的数,使得这些数的和能被M整除. 分析: 设这列数前i项和为s[i], 则一段连续的数的和 a[i]+a[i+1] ...

  9. 我的Win32开发抉择,Delphi老将复出

    这两天在开发公司的一个教学软件客户端,因为要考虑到给PHP.平面设计等班的同学使用,为了避免安装.Net Framework.JRE的麻烦(如果把.Net Framework.JRE打包到安装包,也会 ...

  10. Dynamic CRM 2013学习笔记(三十)Linq使用报错 A proxy type with the name account has been defined by another assembly

    在CRM中使用linq时,有时会报这个错误: A proxy type with the name account has been defined by another assembly. Curr ...