잡다한 자료
[MySQL] 날짜 데이타 출력
돌비
2016. 8. 30. 14:36
* 특정년도의 일자를 쭉 리스트
-- view 생성
create view v_calendar_temp1
as
select 0 n
union all select 1
union all select 2
union all select 3
;
-- view 생성
create view v_calendar_temp2
as
select 0 n
union all select 1
union all select 2
union all select 3
union all select 4
union all select 5
union all select 6
union all select 7
union all select 8
union all select 9
;
-- 쿼리
select (date_format(now(), '%Y0101') + INTERVAL a.n*100 + b.n*10 + c.n DAY) as calendar_date
FROM v_calendar_temp1 a,
v_calendar_temp2 b,
v_calendar_temp2 c
order by 1
;
반응형