1093 - You can't specify target table 'account' for update in FROM clause
目的:查询一张表的相同的两条数据,并删除一条数据。
分析 先查询出相同的数据,然后删除
查询相同的数据
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的更多相关文章
- 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 ...
- [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 ...
- 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 ...
- 关于mysql 5.7版本“报[Err] 1093 - You can't specify target table 'XXX' for update in FROM clause”错误的bug
不同于oracle和sqlserver,mysql并不支持在更新某个表的数据时又查询了它,而查询的数据又做了更新的条件,因此我们需要使用如下的语句绕过: , notice_code ) a) ; 本地 ...
- 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 ...
- [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 ...
- 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 ...
- 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 ...
- 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 现为了查 ...
随机推荐
- Linux定时任务运行thinkPHP某个方法
先上实力: 1.查看正在执行的crontab,用命令crontab -l ,这样就可以看到哪些任务一直在执行了.2.crontab -e 自动打开文件 编辑定时任务程序 在打开的页面中点击“i”键 ...
- Ansible--项目实战
Ansible项目实战lnmp 项目规划 通过ansible roles配置lnmp环境,nginx通过源码编译安装,php通过源码编译安装,mysql通过yum安装(mysql源码编译超级慢)支持系 ...
- 轻量级C#编辑器RoslynPad((基于Roslyn编译器))
简介 RoslynPad是一个Apache 2.0协议开源的轻量级C#编辑器.支持自动完成,语法提示,修改建议等功能.很适合平时随手写个C#程序看看运行结果. 目前版本:0.10.1,无需保存也可以运 ...
- Pytorch并行计算:nn.parallel.replicate, scatter, gather, parallel_apply
import torch import torch.nn as nn import ipdb class DataParallelModel(nn.Module): def __init__(self ...
- Gamification and Game-Based Learning
https://uwaterloo.ca/centre-for-teaching-excellence/teaching-resources/teaching-tips/educational-tec ...
- 无故出现 mysql dead but subsys locked的有关问题
无故出现 mysql dead but subsys locked的问题问题描述:1.mysql安装完成后,使用service mysqld restart总是出现stop mysqld servic ...
- input标签中的accpet
用法 accept 属性只能与 <input type="file"> 配合使用.它规定能够通过文件上传进行提交的文件类型. 提示:请避免使用该属性.应该在服务器端验证 ...
- Likelihood function
似然函数 统计学中,似然函数是一种关于统计模型参数的函数,表示模型参数中的似然性. 给定输出x时,关于参数θ的似然函数L(θ|x)(在数值上)等于给定参数θ后变量X的概率:L(θ|x)=P(X=x|θ ...
- MongoDB权限配置
参考文章:https://blog.csdn.net/qq_26896281/article/details/81206492 https://blog.csdn.net/u012373281/art ...
- Reactive Extensions (Rx) 入门(2) —— 安装 Reactive Extensions
译文:https://blog.csdn.net/fangxing80/article/details/7581937 原文:http://www.atmarkit.co.jp/fdotnet/int ...