본문 바로가기
✅ 문제풀이

프로그래머스 조건에 맞는 도서와 저자 리스트 출력하기 MySQL

by dogfoot.dev 2023. 10. 15.
728x90
728x90

프로그래머스 Level 2 조건에 맞는 도서와 저자 리스트 출력하기 MySQL 문제 풀이 입니다.

링크 : https://school.programmers.co.kr/learn/courses/30/lessons/144854

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

 

✅MySQL 답안 입니다 더보기 클릭!

 

더보기

select book.book_id, author.author_name, DATE_FORMAT(book.published_date, '%Y-%m-%d') as published_date 

from author 

join book on author.author_id = book.author_id 

where book.category = '경제' order by published_date;

 

📌 해설

SQL 고득점 Kit > join 영역 > level2 문제입니다. 

select book.book_id, author.author_name, DATE_FORMAT(book.published_date, '%Y-%m-%d')
as published_date 
from author 
join book on author.author_id = book.author_id 
where book.category = '경제' order by published_date;

author, book 두 테이블을 join 하고 book_id, author_nam, data_format 된 published_date 칼럼으로 조회합니다.

그 중 category 가 '경제'인 것을 찾아 order by 로 published_date를 기준으로 정렬합니다(default 오름차순)

 

 

 

 

::

SQL을 한문제 정도 준비해야 해서 풀어본 join 문제입니다 ㅎㅎ

학교에서 배운 이후로는 거의 안 써본거 같아요. 

간단히 select, update, delete 정도 읽고 쓸줄 아는데 문제를 풀려고 하니 어렵네요ㅠㅠ

 

728x90
반응형