当前位置:网站首页>mysql delete execution error: You can't specify target table 'doctor_info' for update in FROM clause
mysql delete execution error: You can't specify target table 'doctor_info' for update in FROM clause
2022-08-03 16:02:00 【Mindful little mouse】
for some testing reasons,This led to the appearance of two doctors in the doctor tableID相同的数据,也就是所谓的脏数据,So how to delete the redundant one?
一、First filter out the number of bars greater than1条的:
select doctor_id,count(doctor_id) from `doctor_info` where `scale_group_id`="31" group by doctor_id having count(doctor_id)>1
二、Decided to delete that one?max/min
1、max
select max(id) as id from doctor_group_permission where `scale_group_id`="24120868141551631" group by doctor_id having count(doctor_id)>1
2、min
select min(id) as id from doctor_group_permission where `scale_group_id`="24120868141551631" group by doctor_id having count(doctor_id)>1
三、The data is filtered out,直接delete 报错了
delete from doctor_info where id in(select max(id) as id from doctor_info where `scale_group_id`="31" group by doctor_id having count(doctor_id)>1)
四、错误说明
不能先select出同一表中的某些值,再update这个表(在同一语句中),即不能依据某字段值做判断再来更新某字段的值.
Borrow a temporary table to deal with it,Front-end time wrote oneupdate的,链接在此
五、正确delete操作 借用临时表a
delete from doctor_info where id in(select a.id from(select max(id) as id from doctor_info where `scale_group_id`="31" group by doctor_id having count(doctor_id)>1) a)
边栏推荐
- Deep Learning - Install CUDA and CUDNN to implement GPU operation of tensorflow
- 产品以及研发团队有使用专业的办公软件,如禅道、蓝湖等,他们应该如何使用 Tita 系统?
- 指令重排以及案例
- How Navicat connects to MySQL on a remote server
- How to play deep paging with hundreds of millions of data?Compatible with MySQL + ES + MongoDB
- 方舟开服教程win
- 袁小林:沃尔沃专注于出行的安全感,并且把它做到极致
- 托尔斯泰:生活中只有两种不幸
- 方舟开服工具、服务器教程win
- 下午见!2022京东云数据库新品发布会
猜你喜欢

深度学习GPU最全对比,到底谁才是性价比之王?

How to prevent hacking Windows server security Settings

After the cnpm installation is successful, the prompt is not an internal and external command, nor is it a runnable command solution

随笔-UGUI中LayoutGroup来自适应长度图片长度

JD6606SP5_JD6606SSP_JD6606SASP_JD6621W7百盛新纪元授权代理商

瞌睡检测系统介绍

上亿数据怎么玩深度分页?兼容MySQL + ES + MongoDB

指令重排以及案例

【899. 有序队列】

【码蹄集新手村600题】将一个函数定义宏
随机推荐
ReentrantReadWriteLock详解
每日练习------有10个数字要求分别用选择法从大到小输出
移动应用出海,你的“网络优化”拖后腿了吗?
参与便有奖,《新程序员》杂志福利来袭!
在 360 度绩效评估中应该问的 20 个问题
opencv 读取和写入路径有汉字的处理方法
How to get the 2 d space prior to ViT?UMA & Hong Kong institute of technology & ali SP - ViT, study for visual Transformer 2 d space prior knowledge!.
AI+BI+可视化,Sugar BI架构深度剖析
Neural networks, cool?
指令重排以及案例
如何选择合适的损失函数,请看......
开源一夏 | 打工人的第25天-曾经的考研人
技术干货|如何将 Pulsar 数据快速且无缝接入 Apache Doris
出海季,互联网出海锦囊之本地化
如何将二维空间先验注入到ViT中? UMA&港理工&阿里提出SP-ViT,为视觉Transformer学习2D空间先验知识!...
30W 2C(JD6606S + FP6652X2)BOM
您的移动端app安全吗
泰山OFFICE技术讲座:文字边框高度研究
生态剧变,电子签名SaaS模式迎来新突破,网络效应加速到来
2021年数据泄露成本报告解读