문제
풀이
- 두 테이블 JOIN 하기
- ON 넣는 것 잊지 말기
SELECT a.(컬럼1), a.(컬럼2), b.(컬럼3)
FROM (테이블1) AS a
JOIN (테이블2) AS b
ON a.(컬럼1) = b.(컬럼1)
최종 코드
SELECT a.TITLE, a.BOARD_ID, b.REPLY_ID, b.WRITER_ID, b.CONTENTS, DATE_FORMAT(b.CREATED_DATE, '%Y-%m-%d') AS CREATED_DATE
FROM USED_GOODS_BOARD AS a
JOIN USED_GOODS_REPLY AS b
ON a.BOARD_ID = b.BOARD_ID
WHERE a.CREATED_DATE BETWEEN '2022-10-01' AND '2022-10-31'
ORDER BY b.CREATED_DATE ASC, a.TITLE ASC;
728x90