본문 바로가기
  • Welcome.
:: DBMS 🚩/프로그래머스 SQL 고득점 kit 풀이

JOIN>오랜 기간 보호한 동물(1)

by EunBird 2023. 2. 26.
-- JOIN 미사용 
SELECT NAME, DATETIME
FROM ANIMAL_INS
WHERE ANIMAL_ID NOT IN (SELECT ANIMAL_ID FROM ANIMAL_OUTS)
ORDER BY DATETIME 
LIMIT 3
--JOIN 사용 
SELECT A.NAME, A.DATETIME
FROM ANIMAL_INS A LEFT JOIN ANIMAL_OUTS B ON A.ANIMAL_ID = B.ANIMAL_ID
WHERE B.ANIMAL_ID IS NULL
ORDER BY DATETIME 
LIMIT 3
728x90

댓글