目前有一个表XS,表中有xn,xq,xh,xkh等字段信息。表中有几百万条数据。
要求:
1、查询出xh字段重复的数据
2、在查询出xh重复的数据中,查出xkh重复的数据
注:数据要每条显示,不能count(*)
SQLServer上测试通过,显示该记录的全部字段:
1.select * from joke where title in(select title from joke group by title having count(title)>1)
为了在实例表上的测试方便,上面语句假设是title是xh字段,joke是表名,>1说明字段数据存在重复。
2.解决了1,2问题就好解决了:
select * from joke where title in(select title from joke group by title having count(title)>1) and title2 in(select title2 from joke group by title2 having count(title2)>2)
若存在问题,请留言。