코딩테스트/SQL

[JOIN] 조건에 맞는 도서와 저자 리스트 출력하기 (☆☆)

영최 2024. 9. 10. 16:06
728x90

✅ DATE_FORMAT(B.PUBLISHED_DATE,"%Y-%m-%d") 외우기 

"%Y-%m-%d" -> "2020-01-10"

"%y-%m-%d" -> "20-01-10"

"%Y-%m-%d %h:%i:%s" -> "2020-01-10 12:00:00"

"%Y-%m-%d %p %h:%i:%s" -> "2020-01-10 AM 12:00:00"

SELECT B.BOOK_ID,A.AUTHOR_NAME,DATE_FORMAT(B.PUBLISHED_DATE,"%Y-%m-%d")
FROM BOOK AS B
JOIN AUTHOR AS A ON B.AUTHOR_ID = A.AUTHOR_ID
WHERE B.CATEGORY = '경제'
ORDER BY B.PUBLISHED_DATE
728x90