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

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

查询相同的数据

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# 获取指定类型的文件

    C# 获取指定类型的文件 public static List<FileInfo> getFile(string path, string extName) { List<FileI ...

  2. Odoo日历视图详解

    转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/10826148.html 一:日历视图定义 根元素为<calendar>. 主要的属性有:    ...

  3. mysql查询语句中使用星号真的慢的要死?

    前言 之所以写这篇文章,是源于以前看过的关于sql语句优化的帖子,里面明确提到了在sql语句中不要使用 * 来做查询,就像下面的规则中说的 2.尽量避免使用select *,返回无用的字段会降低查询效 ...

  4. centos服务器上线第二个django项目方法。

    阿里云服务器开启端口8001,9001 创建一个虚拟环境 virtualenv -p python3 web2 使虚拟环境生效 source web2/bin/activate 虚拟环境中安装djan ...

  5. 理解迭代器,生成器,yield,可迭代对象

    原文:https://foofish.net/iterators-vs-generators.html 本文源自RQ作者的一篇博文,原文是Iterables vs. Iterators vs. Gen ...

  6. php代理模式(proxy design)

    结构模式最后一个,接着进入行为模式. <?php /* The proxy design pattern functions as an interface to an original obj ...

  7. 2019年牛客多校第二场 F题Partition problem 爆搜

    题目链接 传送门 题意 总共有\(2n\)个人,任意两个人之间会有一个竞争值\(w_{ij}\),现在要你将其平分成两堆,使得\(\sum\limits_{i=1,i\in\mathbb{A}}^{n ...

  8. 第三方百度网盘客户端 PanDownload、速盘、panlight

    PanDownload PanDownload是一款能够快速下载百度网盘内资源的强大工具.PanDownload能够无限速高速下载,满速下载百度云盘里的各种资源.而且PanDownload完全免费,免 ...

  9. MySQL备份python代码

    import os, time, pymysql, shutil from apscheduler.schedulers.blocking import BlockingScheduler # 定时任 ...

  10. JSON Web Token (JWT) - Introduction

    To validate the challenge, connect as admin.------------以admin登陆 https://jwt.io/introduction/        ...