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
注:上面代码中出现的ID1和ID2字段均不是数据表主键。