mysql select dates without tables

后端 未结 3 1271
长发绾君心
长发绾君心 2021-01-04 14:10

I simply need to return a list of all days within a month. I\'m not accessing a specific table. So I need a sql select statement if given the month of February, return the

3条回答
  •  [愿得一人]
    2021-01-04 14:38

    I have slightly augmented to give the all preceeding dates for the last month:

    SELECT (SELECT Date(NOW() - INTERVAL 1 MONTH)) + INTERVAL a + b DAY dte 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 (SELECT Date(NOW() - INTERVAL 1 MONTH)) + INTERVAL a + b DAY < (select date(now())) ORDER BY a + b;

提交回复
热议问题