mysql delete的问题小结

数据库评论868字数 259阅读模式

关于mysql delete的问题,需要的朋友可以参考下。

由于mysql数据库的相关内部问题很文博客-https://www.zhenjiekeji.com/17709.html

导致delete from table where col not in (select col from table group by xx)很文博客-https://www.zhenjiekeji.com/17709.html

会提示报错很文博客-https://www.zhenjiekeji.com/17709.html

我们要做的是很文博客-https://www.zhenjiekeji.com/17709.html

  1. create table tmp selete col from table group by xx;
  2. delete from table where col not in (select col from tmp);
  3. drop table tmp;

今天,在开发自己的项目中需要把项目原来的数据导入到新的系统中,在这个过程中会产生部分脏数据。很文博客-https://www.zhenjiekeji.com/17709.html

我们需要把这部分脏数据删除到,在删除的过程中我写的delete sql语句不能执行不知道为什么,可以同样的语句执行很文博客-https://www.zhenjiekeji.com/17709.html

select 是没有问题的很文博客-https://www.zhenjiekeji.com/17709.html

如:

delete from student a where a.id in (1,2);()

select a.* from student a where a.id in (1,2);()

这是什么原因了呢?

结果处理:

delete 在写操作一张表的时候 不用别名操作成功!

如:

delete from student where id in (1,2);()

我使用mysql版本:5.1.30-community-log

这是在开发中遇到的一个小问题,积累起来。

weinxin
我的微信
微信号已复制
扫一扫更精彩
大家的支持是我更新的动力!!!
匿名

发表评论

匿名网友