时间:2021-07-01 10:21:17 帮助过:18人阅读
2.分组排序
SELECT UId FROM ( SELECT UId,LicenseNo,IF(@grp=a.UId,@rank:=@rank+1,@rank:=1) rank,@grp:=a.UId FROM (SELECT UId,LicenseNo FROM vehicle WHERE 1=1 ORDER BY UId) AS a,(SELECT @grp:=0,@rank:=0) AS b )AS t WHERE t.rank=2;
3.适用于字符串类型,包含中文
SELECT DISTINCT(LicenseNo) FROM vehicle a WHERE 1 = 1 AND ((SELECT COUNT(LicenseNo) FROM vehicle WHERE LicenseNo = a.LicenseNo) > 1) ;
4.适用于字符串类型,不包含中文
SELECT DISTINCT (a.CarVIN) FROM vehicle a LEFT JOIN vehicle b ON a.CarVIN=b.CarVIN WHERE 1=1 AND a.id<>b.Id;
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出 原文链接
mysql千万级数据量查询出所有重复的记录
标签:千万 sel pre 必须 ref 重复数 数据 不包含 多个