编程爱好者之家
删除单个表中一条重复数据
delete from cms_wait_check where id in (select id from (select max(id) as id,count(Mobile) as count from cms_wait_check group by Mobile having count >1 order by count desc) as tab )
删除两个表中重复的数据(只删除一种一张表)
delete cms_wait_check from cms_wait_check inner join cms_my_resource on cms_wait_check.Mobile = cms_my_resource.Mobile
delete cms_wuxiao_resource from cms_wuxiao_resource inner join cms_my_resource on cms_wuxiao_resource.Mobile = cms_my_resource.Mobile
查询出来每条数据重复了多少条在数据库里面
SELECT Mobile,count(*) as count from cms_wait_check group by Mobile having count>1;
删除表中重复数据,只保留一条
delete from cms_wait_check where id not in(select t.id1 from ( (select max(a.id) id1 from cms_wait_check a group by a.Mobile)as t))