小问题,大学问,求解决办法
一张表TABLE,里面有1万条数据,字段ID,CONTENT,其中有些记录ID是一样的,现在求一条SELECT语句,能够取出字段ID重复的所有记录,谢谢
------解决方案--------------------select * 
 from 表名 
 where id in (select id from 表名 group by id having count(*)> 1)
------解决方案--------------------一张表TABLE,里面有1万条数据,字段ID,CONTENT,其中有些记录ID是一样的,现在求一条SELECT语句,能够取出字段ID重复的所有记录,谢谢   
 --取ID 
 select distinct id from tb group by id having count(*) >  1 
 --取ID,content 
 select * from tb where id in (select distinct id from tb group by id having count(*) >  1)
------解决方案--------------------select * from tb 
 where ID in (select ID from tb as t group by ID having(count(1)> =2))
------解决方案----------------------1 
 select * from 表 where id in (select id from 表 group by id having(count(*))> 1)   
 --2 
 select * from 表 a where  exists (select 1 from 表 where id=a.id group by id having(count(*))> 1)   
 --2 
 select * from 表 a where not exists (select 1 from 表 where id=a.id group by id having(count(*))=1)