日期:2014-05-18  浏览次数:20365 次

如何查询两个字段重复数据
如题,求表里某两个字段完全重复的数据列表

------解决方案--------------------
select col1,col2 from tb
group by col1,col2 having count(1) > 1
------解决方案--------------------
如题,求表里某两个字段完全重复的数据列表

--仅仅显示这两列
select col1,col2 from tb group by col1,col2 having count(*) > 1

--显示所有列
select * from tb where cast(col1 as varchar) + cast(col2 as varchar) in
(select cast(col1 as varchar) + cast(col2 as varchar) from (select col1,col2 from tb group by col1,col2 having count(*) > 1)t)