筛选出某张表中两个字段都相同的记录

项目中遇到的 :

shop_id   form_id
SELECT shop_id,form_id FROM user_shop GROUP BY shop_id,form_id HAVING COUNT(shop_id)>=2
AND form_id IN
(SELECT form_id FROM user_shop GROUP BY form_id HAVING COUNT(form_id)>=2);

 

 

以下是网上找的,不知是否可行

select * from tb where name in (SELECT name FROM tb GROUP BY name HAVING COUNT(name)=1)
AND dw IN
(SELECT dw FROM tb GROUP BY dw HAVING COUNT(dw)=1);

展开阅读全文

没有更多推荐了,返回首页