使用mysql在删除表中重复记录

delete from user where username in (select user name form(select username from user group by username having count(username)>1));

遇到mysql报错You can't specify target table for update in FROM clause

上网百度了下原来是mysql中不允许先select出同一表中的某些值,再update这个表(在同一语句中),这个问题只出现于mysql,sqlserver和oracle不会出现此问题

解决办法:将select出的结果再通过中间表select一遍

delete from user where username in (select a.username from(select username from user group by username having count(username)>1)a);

这样delete和select的就不是同一个表了

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

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

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

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

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

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

  7. 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这个表( ...

  8. 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这个表( ...

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

随机推荐

  1. 浅谈PHP在各系统平台下的换行符

    <?php echo 'aaa\n';//用于linux.unix平台C的换行也是如此 echo 'bbb\r';//用于mac平台 echo 'ccc\r\n';//用于windows平台 / ...

  2. storm安装(3)storm本身的安装

    (6)下载storm包放入home文件夹中, 这里我用的版本是storm-0.8.2.zip 添加权限 chmod +x storm-0.8.2.zip 进行文件的解压 unzip storm-0.8 ...

  3. Hadoop 使用FileSystem API 读取数据

    代码: package com.hadoop; import java.io.IOException; import java.io.InputStream; import java.net.URI; ...

  4. AngularJS1

    Ⅰ.AngularJS的点点滴滴--引导   AngularJS已经被很多人像炒冷饭一样炒过啦,大部分都是直接复制官方文档没有说明一些注意事项,不过什么都要从头开始吧 ###页面引导实例化 * * * ...

  5. 一个人开发的html整站源码分享网站就这么上线了

    项目我采用了纯静态html+动态搜索的模式,就是说详情页.主页等纯静态页面,仅搜索页面采用数据库访问搜索,搜索结果分为静态和动态,如果输入的关键字是已存在的标签就静态展示,否则就动态展示,这么做的好处 ...

  6. dtrace sample

    #!/usr/sbin/dtrace -s #pragma D option flowindent /* monitor file open */ syscall::open:entry { prin ...

  7. .Net 异步随手记(二)

    Task.ContinueWith 这货,和 await 一样有“陷阱”.^^,因为写 ContinueWith 不能直观如人的“过程性”思维,写在 ContinueWith 括号里的部分不一定只在发 ...

  8. 长度为n的数组,有一个数重复出现了n/2+1次,找出(三种方法)

    问题: 长度为n的数组,有一个数重复出现了n/2+1次,找出这个数:   解决: 比较直接的思路是遍历每个元素,让其与剩下其他元素比较,相等一次计数器sum++,直到sum=n/2+1为止: #inc ...

  9. 竞价广告系统-ZooKeeper介绍

    ZooKeeper介绍 为了讲述的完整性,介绍一下ZooKeeper.ZooKeeper在Index和Ad Server里使用比较多,虽然它可能没有google的Chubby好,但它是开源的工具.举一 ...

  10. OpenXml操作Word的一些操作总结.

    OpenXml操作Word的一些操作总结. OpenXml相对于用MS提供的COM组件来生成WORD,有如下优势: 1.相对于MS 的COM组件,因为版本带来的不兼容问题,及各种会生成WORD半途会崩 ...