Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Cara mendapatkan daftar bulan antara dua tanggal di mysql

Demo SQLFiddle

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


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Aplikasi Web PHP:pertanyaan praktik terbaik desain database mysql

  2. Bagaimana cara mendapatkan tipe data kolom tabel mysql?

  3. SQLSTATE[HY093] :pernyataan pdo saat dimasukkan ke mysql db

  4. Kesalahan umum:1366 Nilai integer salah dengan pembaruan Doctrine 2.1 dan Zend Form

  5. cara menghitung total komentar