sql查找多字段重复记录

编程开发 / / at

查询post_title重复记录以及重复数量
select ID,post_title,post_date,count(*) as count from news_posts group by post_date having count>1
查询post_title和post_date两个字段重复记录
select ID,post_title,post_date from news_posts group by post_title,post_date having count(*)>1

查询post_title和post_date两个字段重复记录,并列出所有重复记录
select * from news_posts a join (select post_date,post_title from news_posts group by post_date,post_title having count(*)>1) b on a.post_title=b.post_title and a.post_date=b.post_date order by a.post_date ,a.post_title

发表评论

电子邮件地址不会被公开。 必填项已用*标注