删除mysql数据库中的重复数据记录方法

  • A+
所属分类:数据库

mysql中select distinct * from text不能显示不重复的记录,而是直接全部显示

采用的是下面的方法可删除,假设重复的是test数据库中的title字段

  1. create table bak as (select * from test group by title having count(*)=1);
  2. insert into bak (select * from test group by title having count(*)>1);
  3. truncate table test;
  4. insert into test select * from bak;

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: