년도및, 날짜나, 시간별로 숫자 리스트를 임의로 만들어야 할 수도 있다.
나는 예제로, 2018 부터 2021까지의 숫자 리스트를 만들려고 한다,
select
year_list
from (
select
@year := @year - 1 as year_list
from
information_schema.tables a
, information_schema.tables b
, (select @year := 2022) c_year
)year_ilst_cut
where year_ilst_cut.year_list between '2018' and '2021';
또 다른 예
select
year_list,
date_add('2021-01-01', interval year_list - 1 year) as year_date_add,
Date_format(date_add('2021-01-01', interval year_list - 1 year),'%Y-%m-%d')as year_Date_format
from(
select
@year := @year +1 as year_list
from
information_schema.tables a
, information_schema.tables b
, (select @year := 0) c_year
)x
'DBMS > MySQL' 카테고리의 다른 글
[MySQL] mysql 외부 접속시 connection locked 현상 (Unblock with 'mysqladmin flush-hosts (0) | 2025.02.17 |
---|---|
[MySQL] rownum 순번 매기기 (0) | 2025.02.17 |
[MySQL] 세자리마다 콤마찍기 (0) | 2025.02.17 |
[MySQL] 데이터베이스 테이블수 및 정보 조회, 컬럼 수 및 조회 (0) | 2025.02.17 |
[MySQL] 데이터베이스 용량 확인 / 버전확인 (0) | 2025.02.17 |