728x90
반응형
1. 날짜테이블을 생성하기 위한 더미 테이블 생성
create table t (n int);
insert into t values (1);
// 입력할 년도의 날짜 수만큼 행을 생성한다.
insert into t select * from t
2. 날짜테이블 생성
create table date_t (d date, ds char(8));
insert into date_t
select d, date_format(d, '%Y%m%d') from (
select @rnum:=@rnum+1 as rownum, date(adddate('2014-01-01', interval @rnum day)) as d
from (select @rnum:=-1) r, t
) t
where year(d) < 2024;
728x90
반응형
'Programming > MySQL' 카테고리의 다른 글
[MySQL] 외부접속 허용하기 (0) | 2015.06.30 |
---|---|
[MySQL] mysql csv 입력 (0) | 2015.06.30 |
auto_increment initialization (초기화) (0) | 2015.06.30 |
[MySQL] 컬럼 & 필드 합치기 concat(), group_concat() (0) | 2015.06.30 |
[MySQL] 문자 치환하기 REPLACE() (0) | 2015.06.30 |
댓글