查找含匹配列的行
//--为col2与col3查找出重复的行
//match_cols表
row_no col2 col3
------ ---------- ----------
1 c d
2 a a
3 a d
4 c b
5 c c
6 b c
7 c a
8 c b
9 c d
10 d d
(10 row(s) affected)
结果:
row_no col2 col3
------ ---------- ----------
4 c b
8 c b
1 c d
9 c d
(4 row(s) affected)
我 写的一个语句
select a.id,a.col1,a.col2 from table5 a
inner join table5 b on a.col1=b.col1 and a.col2=b.col2
group by a.id,a.col1,a.col2
having count(a.id)>=2
order by a.col1,a.col2
得结果一样。效率还不高.
本文介绍了一种使用T-SQL来查找表中具有重复col2和col3列值的行的方法,并提供了一个具体的例子来展示如何通过内连接查询来找到这些重复的数据行。

被折叠的 条评论
为什么被折叠?



