Convert query from MySql to Sqlite

前端 未结 2 1744
忘了有多久
忘了有多久 2021-01-26 14:59

I need to convert this query from MySQL format to SQLite. I\'m trying myself but I\'ve found some difficulty.

In SQLite, the curdate() and the interval functions do not

2条回答
  •  太阳男子
    2021-01-26 15:19

    Here is the basic syntax:

    select a.Date 
    from (select date('now', '-'||(a.a + (10 * b.a) + (100 * c.a))|| ' days') 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
               ) 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
               ) 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
               ) c
        ) a;
    

    I left out the where clause because those dates are more than 1000 days in the past, so they won't select anything anyway.

提交回复
热议问题