MySQLで動的に連番を作る
SELECT @seq_no := 1 AS seq_no
UNION
SELECT @seq_no := @seq_no + 1 AS seq_no
FROM information_schema.COLUMNS
LIMIT 10;
便利な連番 先月と今月の日付一覧
code:sql
select *
from (
select year(now()) year
) year
inner join (
select month(now()) month
union
select month(date_add(now(), interval -1 month))
from information_schema.COLUMNS
) month
inner join (
select @seq_no := 1 day
union
select @seq_no := @seq_no + 1 AS seq_no
from information_schema.COLUMNS
limit 31
) day on month.month != month(now()) or (month.month = month(now()) and day.day <= day(now()))