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的更多相关文章

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

  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错误解决方法

    mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...

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

  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错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...

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

  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 for update in FROM clause UPDATE edu_grade_hgm_1 ' W ...

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

随机推荐

  1. Python基础教程笔记——第2章:列表和元组

    python shell 里重复上一次的命令:Alt+p 2.3 列表:Python的苦力 (1)list函数 (2)列表赋值,不蹦蹦为一个元素不存在的位置赋值 (3)删除元素,del name[1] ...

  2. topcoder 650 srm

    500 遇到这种构造题 就给跪了 比赛的时候想很多方法 DP,贪心,模拟 发现越写越烦琐.看到别人出这么快,肯定又是奇葩思路. 后来居然想到 2^50的暴力 +剪枝 不过暴力肯定卡你 IDEA: 只要 ...

  3. java面向对象基础编程题

    第一题: 设计一个形状类Shape,方法:求周长和求面积.形状类的子类:Rect(矩形),Circle(圆形).Rect类的子类:Square(正方形).不同的子类会有不同的计算周长和面积的方法1.总 ...

  4. jfree-生成xy图

    需要导入的包: import org.jfree.chart.*; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data ...

  5. 转:TLV 格式及编解码示例

    TLV是一种可变格式,意思就是: Type类型, Lenght长度,Value值: Type和Length的长度固定,一般那是2.4个字节(这里统一采用4个字节): Value的长度有Length指定 ...

  6. 海量数据处理面试题学习zz

    来吧骚年,看看海量数据处理方面的面试题吧. 原文:(Link, 其实引自这里 Link, 而这个又是 Link 的总结) 另外还有一个系列,挺好的:http://blog.csdn.net/v_jul ...

  7. [转]图解eclipse 查看原始类出现The jar file rt.jar has no source attachment

    原文:http://blog.csdn.net/u011514810/article/details/53196371 ---------------------------------------- ...

  8. 各项异性滤波简单介绍Anisotropic Filtering(AF)

    本文主要整理简绍来自互联网的各项异性滤波的知识. 原文链接:http://www.linuxgraphics.cn/graphics/using_anisotropic_texture_filteri ...

  9. MySQL Study之--MySQL用户及权限管理

    MySQL Study之--MySQL用户及权限管理     MySQLserver通过MySQL权限表来控制用户对数据库的訪问.MySQL权限表存放在mysql数据库里.由mysql_install ...

  10. 3 TypeScript 语法特性

    一.类型注解(Type annotations) TypeScript 通过类型注解提供静态类型以在编译时启动类型检查,简单来说,就是指定数据类型,它会在代码运行的时候,对传入的数据进行数据类型匹配检 ...