目的:查询一张表的相同的两条数据,并删除一条数据。

分析 先查询出相同的数据,然后删除

查询相同的数据

SELECT a.id FROM account a GROUP BY a.username HAVING COUNT(a.username)>1;

DELETE FROM account WHERE id = (SELECT a.id FROM account a GROUP BY a.username HAVING COUNT(a.username)>1) ;

1093 - You can't specify target table 'account' for update in FROM clause

不能为FROM子句中的更新指定目标表'account'。

修改后:

DELETE FROM account WHERE id =

(SELECT t.id from

(SELECT a.id FROM account a GROUP BY a.username HAVING COUNT(a.username)>1) t
);

1093 - You can't specify target table 'account' for update in FROM clause的更多相关文章

  1. Mysql update in报错 [Err] 1093 - You can't specify target table 'company_info' for update in FROM clause

    Mysql update in报错 解决方案: [Err] 1093 - You can't specify target table 'company_info' for update in FRO ...

  2. [Err] 1093 - You can't specify target table 's' for update in FROM clause

    [Err] 1093 - You can't specify target table 's' for update in FROM clause 执行SQL DELETE from book WHE ...

  3. MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause

    MySQL中执行sql语句错误 Error Code: 1093. You can't specify target table 'car' for update in FROM clause 201 ...

  4. 关于mysql 5.7版本“报[Err] 1093 - You can't specify target table 'XXX' for update in FROM clause”错误的bug

    不同于oracle和sqlserver,mysql并不支持在更新某个表的数据时又查询了它,而查询的数据又做了更新的条件,因此我们需要使用如下的语句绕过: , notice_code ) a) ; 本地 ...

  5. MySQL 1093 - You can't specify target table 'sc' for update in FROM clause

    错误代码如下: #(8) 把"邓维杰"同学的成绩全部删除. SELECT * FROM sc WHERE EXISTS(SELECT * FROM student WHERE st ...

  6. [Err] 1093 - You can't specify target table 'master_data' for update in FROM clause

    delete from master_data where category_id not in (select category_id from master_data a, bc_category ...

  7. MySQL: [Err] 1093 - You can't specify target table 'bk' for update in FROM clause

    错误的意思说,不能先select出同一表中的某些值,再update这个表(在同一语句中). 例如下面这个sql: delete from tbl where id in (        select ...

  8. django.db.utils.OperationalError: (1093, "You can't specify target table 'xxx' for update in FROM clause")

    这个错误的意思是,不能在update某张表的where条件中,再次select这张表的某些值作为筛选条件,比如: update message set content = "hello&qu ...

  9. MySQL - 1093异常 - You can't specify target table 't' for update in FROM clause

    有一个表示地区的表,表结构与数据大概如下表. ID NAME PARENT_ID 1 中国 2 广东省 1 3 广州市 2 4 荔湾区 3 5 越秀区 3 6 番禺区 3 7 小谷围街道 6 现为了查 ...

随机推荐

  1. c#: 剪切板监视实现

    CR TubeGet中有用户需要剪切板监视功能,记录代码以做备忘: using System; using System.Runtime.InteropServices; using System.W ...

  2. kubelet 预留system、kube资源

    kubelet 预留system.kube资源 Kubernetes 的节点可以按照 Capacity 调度.默认情况下 pod 能够使用节点全部可用容量.这是个问题,因为节点自己通常运行了不少驱动 ...

  3. qt5.12 解决显示中文乱码问题

    在菜单栏   文件->选项,找到文本编辑器 文件编码设置如图 在cpp文件中加入 #pragma execution_character_set("utf-8") 之后就可以 ...

  4. django项目中form表单和ajax的文件上传功能。

    form表单文件上传 路由 # from表单上传 path('formupload/',apply.formupload,name='formupload/'), 方法 # form表单文件上传 de ...

  5. 阿里巴巴Java开发手册(华山版).pdf

    https://github.com/alibaba/p3c/blob/master/阿里巴巴Java开发手册(华山版).pdf

  6. python笔记43-加解密AES/CBC/pkcs7padding

    前言 有些公司对接口的安全要求比较高,传参数的时候,不会明文的传输,先对接口加密,返回的数据也加密返回. 目前比较常见的加密方式是AES/CBC/pkcs7padding. AES五种加密模式 在AE ...

  7. static final 和final的区别

    学习java的时候常常会被修饰符搞糊涂,这里总结下static final和final的区别. static是静态修饰关键字,可以修饰变量和程序块以及类方法: 当定义一个static的变量的时候jvm ...

  8. ArcSDE SQL Server 创建地图数据库

    1.安装并破解: ArcGIS 10.2 ArcSDE 10.2 Sql Server 2008 R2 本文重点关注Sql Server和ArcSDE配置问题,安装破解过程略. 2.配置Sql Ser ...

  9. Spring Cloud Consul Config 知识点

    Spring Cloud Consul Config 是 Config Server 和 Client的替代方案. 搭建一个配置中心,可以选择的方案: Spring Cloud Config 或者 S ...

  10. 18、Python模块基础

    一.模块 模块可以看成是一堆函数的集合体. 一个py文件内部就可以放一堆函数,因此一个py文件就可以看成一个模块. 如果这个py文件的文件名为module.py,模块名则是module. 1.模块的四 ...