Mysql
 sql >> Datenbank >  >> RDS >> Mysql

So erhalten Sie eine Liste der Monate zwischen zwei Daten in MySQL

SQLFiddle-Demo

select 
DATE_FORMAT(m1, '%b %Y')

from
(
select 
('2013-01-23' - INTERVAL DAYOFMONTH('2013-01-23')-1 DAY) 
+INTERVAL m MONTH as m1
from
(
select @rownum:[email protected]+1 as m from
(select 1 union select 2 union select 3 union select 4) t1,
(select 1 union select 2 union select 3 union select 4) t2,
(select 1 union select 2 union select 3 union select 4) t3,
(select 1 union select 2 union select 3 union select 4) t4,
(select @rownum:=-1) t0
) d1
) d2 
where m1<='2014-04-01'
order by m1