-- 코드를 입력하세요
-- SELECT 아이디
-- FROM CART_PRODUCTS
-- WHERE 우유 구입
-- AND 요거트 구입
-- SELECT CART_ID
-- FROM CART_PRODUCTS
-- WHERE NAME = 'Yogurt';
-- SELECT CART_ID
-- FROM CART_PRODUCTS
-- WHERE NAME = 'Milk';
-- INTERSECT 이용
SELECT CART_ID
FROM(
SELECT CART_ID
FROM CART_PRODUCTS
WHERE NAME = 'Yogurt'
INTERSECT
SELECT CART_ID
FROM CART_PRODUCTS
WHERE NAME = 'Milk'
)
ORDER BY CART_ID;
-- SELF JOIN 이용
SELECT A.CART_ID
FROM CART_PRODUCTS A JOIN CART_PRODUCTS B
ON A.CART_ID = B.CART_ID
WHERE A.NAME = 'Yogurt'
AND B.NAME = 'Milk'
ORDER BY A.CART_ID;