sql >> Database teknologi >  >> RDS >> Mysql

MySQL viser alle datoer i mellem området

Du kan bruge følgende til at generere din liste over datoer:

select a.Date,  s.*
from 
(
  select curdate() + INTERVAL (a.a + (10 * b.a) + (100 * c.a)) DAY as Date
  from (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as a
  cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as b
  cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as c
) a
inner join schedule s
  on a.Date >= s.fromDate 
  and a.Date <= s.toDate

Se SQL Fiddle with Demo



  1. Sådan indstilles max_connections i MySQL Programmatisk

  2. PostgreSQL Upsert differentiere indsatte og opdaterede rækker ved hjælp af systemkolonner XMIN, XMAX og andre

  3. Sådan tilføjes et logo til en formularhoved i Microsoft Access

  4. få 2 dage siden forespørgsel i mysql