【MySQL】解决You can't specify target table 'user_cut_record_0413' for update in FROM clause
问题
You can't specify target table 'user_cut_record_0413' for update in FROM clause
原因
待更新/删除的数据集与查询的数据集撞车了,可以给后面的数据集加个别名,来解决撞车问题
报错语句
delete from user_cut_record_0413 where record_id IN ( select record_id from user_cut_record_0413 GROUP BY record_id HAVING COUNT(record_id) > 1 )
解析语句
delete from user_cut_record_0413 where record_id IN ( select record_id from user_cut_record_0413 GROUP BY record_id HAVING COUNT(record_id) > 1 )
解决方法
delete from user_cut_record_0413
where record_id IN (
select record_id from (select * from user_cut_record_0413) t
GROUP BY record_id
HAVING COUNT(record_id) > 1
)
其实就是把后面的user_cut_record_0413 改成 (select * from user_cut_record_0413) t
【MySQL】解决You can't specify target table 'user_cut_record_0413' for update in FROM clause的更多相关文章
- 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 ...
- update mysql row (You can't specify target table 'x' for update in FROM clause)
sql语句(update/delete都会出现此问题) update x set available_material_id = null where id not in (select id fro ...
- 解决MYSQL的You can't specify target table 'xxxxxxxxxx' for update in FROM clause
出现这个问题的MYSQL的SQL语句形如: DELETE FROM xxxxa WHERE EXISTS (SELECT * FROM xxxx1 WHERE xxxxa.xxid=123) 解决方法 ...
- mysql:You can't specify target table 'bpm_tksign_data' for update in FROM clause
UPDATE bpm_tksign_data WHERE actinstid ' AND nodeid = 'SignTask1' AND batch = ( SELECT max(a.batch) ...
- mysql:You can't specify target table 'sessions' for update in FROM clause
更新数据时,在where条件子句里面如果想使用子查询按条件更新部分数据,需要将查询的结果设为临时表.可以参考: https://blog.csdn.net/poetssociety/article/d ...
- mysql中更新或者删除语句中子语句不能操作同一个表You can't specify target table 'test' for update in FROM clause
问题描述:有个数据表test,有个字段value,如下 mysql> select * from test;+----+------------------------------------+ ...
- 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 ...
- 错误:You can't specify target table 'xxx' for update in FROM clause的解决
问题: 今天在MySQL数据库删除重复数据的时候遇到了一个问题.如下脚本: DELETE FROM tempA WHERE tid IN ( SELECT MAX(tid) AS tid FROM t ...
- 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 ...
随机推荐
- BZOJ3230 相似子串 字符串 SA ST表
原文链接http://www.cnblogs.com/zhouzhendong/p/9033092.html 题目传送门 - BZOJ3230 题意 给定字符串$s$.长度为$n$. 现在有$Q$组询 ...
- HDU6031 Innumerable Ancestors 倍增 - 题意详细概括 - 算法详解
去博客园看该题解 题目 查看原题 - HDU6031 Innumerable Ancestors 题目描述 有一棵有n个节点的有根树,根节点为1,其深度为1,现在有m个询问,每次询问给出两个集合A和B ...
- 012 pandas与matplotlib结合制图
这里以后再补充. 1.折线图
- 堆排序算法(Java实现)
将待排序的序列构造成一个大顶堆(从大到小排要构造成小顶堆).此时,整个序列的最大值就是堆顶的根节点,将他和末尾元素交换,然后将剩余的length-1个节点序列重新构造成新的堆.重复执行,便能得到一个有 ...
- php(apache)切换版本
php(apache)切换版本 1.brew link php@7.1 2.上两行写入 ~/.bash_profile文件 3.source ~/.bash_profile 4.sudo vi /et ...
- mybatis相关知识
@param解释为映射mapper.xml中的传参 mybatis中批量新增时用foreach循环,注意其中的collection属性,有list,数组 注意foreach中sql函数的写法,orac ...
- java.io.File中字段的使用
File.pathSeparator指的是分隔连续多个路径字符串的分隔符,例如:Java -cp test.jar;abc.jar HelloWorld就是指“;” File.separa ...
- centos7如何添加开机启动服务/脚本
一.添加开机自启服务 在centos7中添加开机自启服务非常方便,只需要两条命令(以Jenkins为例): systemctl enable jenkins.service #设置jenkins服务为 ...
- webstorm 2017 激活破解方法大全
webstorm 作为最近最火的前端开发工具,也确实对得起那个价格,但是秉着勤俭节约的传统美德,我们肯定是能省则省啊. 方法一:(更新时间:2018/4/8)v3.3 注册时,在打开的License ...
- vue源码的构建
一.vue构建的基本了解 1,开始学习vue的源码的学习,vue.js是基于rollup构建的 它的配置在 scripts下面 rollup是webpack的简小版针对于js进行压缩的,没有提供复杂的 ...