Q.

풀이 1
- date_format(published_date, '%Y-%m-%d')
- published_date를 년-월-일 형식으로 포맷
- published_date like '2021%'
- published_date 컬럼값 중 2021로 시작하는 모든 데이터
select book_id, date_format(published_date, '%Y-%m-%d') as published_date
from book
where category = '인문' and published_date like '2021%'
order by published_date asc;풀이 2
- published_date >= '2021-01-01' and published_date <= '2021-12-31'
- 날짜를 나타내는 컬럼값도 대소 비교 가능
- 2021-01-01 ~ 2021-12-31
select book_id, date_format(published_date, '%Y-%m-%d') as published_date
from book
where category = '인문'
and published_date >= '2021-01-01' and published_date <= '2021-12-31'
order by published_date asc;Share article