server怎么查重復數據?
1、最直觀的思路:要知道所有名字有重復人資料,首先必須知道哪個名字重復了:
select name from emp group by name having count(*)>1所有名字重復人的記錄是:select * from emp where name in (select name from emp group by name having count(*)>1)2、稍微再聰明一點,就會想到,如果對每個名字都和原表進行比較,大于2個人名字與這條記錄相同的就是合格的 ,就有:
select * from emp where (select count(*) from emp e where e.name=emp.name) >1
上一篇怎么把自媒體做大做強