MySQL之——DELETE NOT IN 删除问题

MySQL比较恶心的一个delete in操作

MySQL中

delete from tableA where id not in  (1,2,3);

是没有问题的

delete from tableA where id not in (select id from tableB)

也是没有问题的

但是

delete from tableA where id not in (select id from tableA)

就TMD有问题了。

解决办法是给里面的子查询建立表别名

delete from tableA ( select * from (select id from tableA) t)
发布了1303 篇原创文章 · 获赞 1993 · 访问量 512万+

猜你喜欢

转载自blog.csdn.net/l1028386804/article/details/103136595