¡¡¡¡
sql²éѯij×ֶεÄÏàֵͬ:
SELECT * FROM table WHERE col in (SELECT col FROM table GROUP BY col HAVING COUNT (col) >1);
˳´øËµÒ»ÏÂwhereºÍhaving£º
select * from table
where ¡¤¡¤¡¤(Ö»ÄܶԷÖ×éǰµÄÊôÐÔ½øÐÐɸѡ)
group by ¡¤¡¤¡¤(°´Ä³¸ö×ֶηÖ×é)
having ¡¤¡¤¡¤(Ö»ÄܶԷÖ×éºóµÄÿ¸ö×éµÄÕûÌåÊôÐÔ½øÐÐɸѡ£¬ÓþۺϺ¯ÊýÌåÏÖ)
--²»Ê¹ÓÃgroup by¾ÍĬÈϱíµÄÕûÌåΪһ×é
ʵÀý£º
²éѯ³öÖØ¸´¼Ç¼
select * from Êý¾Ý±í WHERE ÖØ¸´¼Ç¼×Ö¶Î in ( select ÖØ¸´¼Ç¼×Ö¶Î from Êý¾Ý±í group by ÖØ¸´¼Ç¼×Ö¶Î having count(ÖØ¸´¼Ç¼×Ö¶Î)>1)