sql urutan hari tanpa tabel
1. MySQL/MariaDB. gak paham sama sekali, gimana cara kerja skrip ini.
https://stackoverflow.com/a/5081980
set @awal := '2023-03-01', @akhir := '2023-03-31'; SELECT @awal + INTERVAL a + b DAY `date` FROM (SELECT 0 a UNION SELECT 1 a UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 ) d, (SELECT 0 b UNION SELECT 10 UNION SELECT 20 UNION SELECT 30 UNION SELECT 40) m WHERE @awal + INTERVAL a + b DAY <= @akhir ORDER BY a + b limit 9992. MariaDB. keren banget ini, langsung paham (output nya sama dengan #1). https://stackoverflow.com/a/54833745 https://mariadb.com/kb/en/sequence-storage-engine/
set @awal := '2023-03-01', @akhir := '2023-03-31'; SELECT @awal + interval seq day as `date` FROM seq_0_to_365 WHERE @awal + interval seq day <= @akhir limit 999
Komentar
Posting Komentar
Komentar ...