=============================================== =========
我只想获得技能栏中同时拥有2和14的用户。答案应该是" 2"
答案 0 :(得分:1)
试试这个:
SELECT seekerID
FROM mytable
WHERE skillID IN (2, 14)
GROUP BY seekerID
HAVING COUNT(DISTINCT skillID) = 2
只有在DISTINCT
个skillID
值出现多次的情况下才需要 seekerID
个关键字。
答案 1 :(得分:0)
最简单的方法是
select seekerID, count(*) as cnt
from table_name
where skillid in (2,14)
group by seekerID
having cnt = 2
答案 2 :(得分:0)
使用它:
select seekerID from table_name where skillid="2" and seekerID = ( select author from table_name where skillid="14")