mysql 删除相同的记录
2012-04-12 11:49
197 查看
不能直接用delete from test where id not in (select id from test);
、、要用
drop TABLE if EXISTS temp;
CREATE TABLE temp as select min(id) as id from test GROUP BY name;
delete from test where id not in (select id from temp);
、、要用
drop TABLE if EXISTS temp;
CREATE TABLE temp as select min(id) as id from test GROUP BY name;
delete from test where id not in (select id from temp);
相关文章推荐
- Mysql如何删除表里相同的记录
- mysql中多表删除其中ID相同记录的方法
- mysql中多表删除其中ID相同记录的方法
- MYSQL删除一个字段相同记录,保留ID最小记录
- mysql插入数据时候先检查表中有没有相同的数据如果有就删除原来记录插入,没有就直接插入
- mysql-删除/更新相同的记录的前n条
- mysql,oracle里删除重复记录,只保留一条(除了自增长字段,其他的字段完全相同为相同记录)
- php中批量删除Mysql中相同前缀的数据表
- Mysql 删除包含或者不包含某字符的记录
- Mysql中批量删除相同表前缀的数据表 sql语句
- MySQL重复记录删除
- mysql同时删除多张开头相同的表
- MYSQL删除表的记录后如何使ID从1开始
- MySql触发器之--主表记录删除并备份以及相关联子表记录自动删除
- 删除MySql表中的大量记录后,文件不变小的解决方法
- 关于MySQL的按照id进行删除记录
- 用一条sql语句删除表中所相同的记录
- mysql支持跨表delete删除多表记录
- mysql删除重复记录
- MySQL查询及删除重复记录的方法