프로그래머스 - 2021 Dev-Matching: 웹 백엔드 개발자(상반기) : 헤비 유저가 소유한 장소

문제

https://programmers.co.kr/learn/courses/30/lessons/77487

정답

SELECT * FROM PLACES
WHERE HOST_ID IN (SELECT HOST_ID FROM PLACES GROUP BY HOST_ID HAVING count(*) >= 2)
ORDER BY ID

EXISTS 를 사용한 방법

SELECT * FROM PLACES P1
WHERE EXISTS (
    SELECT HOST_ID FROM PLACES P2
    WHERE P1.HOST_ID = P2.HOST_ID
    GROUP BY HOST_ID
    HAVING COUNT(ID) >= 2
)
ORDER BY ID ASC;