如果想查询数据表中某一个字段重复(这里假设这个字段名是ID1),可以使用以下SQL语句。
select Table1.* from Table1 right join (
select ID1 From Table1 Group by ID1 having Count(ID1) > 1 ) T on Table1.id1 = T.id1
如果想查询数据表某两个字段重复,则可以使用如下语句查询。
select Table1.*
from Table1 right join (
select ID1, ID2 From Table1 Group by ID1, ID2 having Count(ID1) > 1 and Count(ID2) > 1 ) T
on Table1.id1 = T.id1 and Table1.id2 = T.id2
select Table1.* from Table1 right join (
select ID1 From Table1 Group by ID1 having Count(ID1) > 1 ) T on Table1.id1 = T.id1
如果想查询数据表某两个字段重复,则可以使用如下语句查询。
select Table1.*
from Table1 right join (
select ID1, ID2 From Table1 Group by ID1, ID2 having Count(ID1) > 1 and Count(ID2) > 1 ) T
on Table1.id1 = T.id1 and Table1.id2 = T.id2