select A.* from 表 A, (select aa,bb from 表 group by aa,bb) B where A.aa=B.aa and A.bb=B.bb
select * from 表 a where exists(select count(*) from 表 where aa=a.aa and bb=a.bb and cc=a.cc group by aa,bb having count(*)>1)
SELECT A.* FROM yourTable A INNER JOIN ( SELECT aa, bb FROM yourTable GROUP BY aa, bb HAVING COUNT(*) > 1 ) B ON B.aa = A.aa AND B.bb = A.bb ORDER BY A.aa, A.bb
楼上的理解错了,应该是找出aa、bb重复的纪录吧
select a.* from table a, (select aa,bb from table group by aa,bb) b where a.aa=b.aa and a.bb=b.bb不知道可以吗?
有没有试过: select * from 表 a where exists(select count(*) from 表 where aa=a.aa and bb=a.bb and cc=a.cc group by aa,bb having count(*)>1)
用这个绝对可以 select * from table_name a ,(select aa,bb from table_name group by aa,bb having count(*) > 1) b where a.aa = b.aa and a.bb=b.bb
前面应该是a.* select a.* from table_name a ,(select aa,bb from table_name group by aa,bb having count(*) > 1) b where a.aa = b.aa and a.bb=b.bb
where exists(select count(*) from 表 where aa=a.aa and bb=a.bb and cc=a.cc
group by aa,bb having count(*)>1)
FROM yourTable A
INNER JOIN (
SELECT aa, bb
FROM yourTable
GROUP BY aa, bb
HAVING COUNT(*) > 1
) B ON B.aa = A.aa
AND B.bb = A.bb
ORDER BY A.aa, A.bb
select * from 表 a
where exists(select count(*) from 表 where aa=a.aa and bb=a.bb and cc=a.cc
group by aa,bb having count(*)>1)
select * from table_name a ,(select aa,bb from table_name group by aa,bb having count(*) > 1) b where a.aa = b.aa and a.bb=b.bb
select a.* from table_name a ,(select aa,bb from table_name group by aa,bb having count(*) > 1) b where a.aa = b.aa and a.bb=b.bb