(MySQL)如何得到Date Range之間的所有日子

WITH
cte_name [(col1, col2, ...)]
AS ( subquery )
Select col1, col2, .. from cte_name;
WITH RECURSIVE
cte_name [(col1, col2, ...)]
AS
(
Selet a, b, ... n from table_name
UNION ALL
Select col1, col2, ...coln from cte_name
WHERE terminating condition
)
Select col1, col2, .. from cte_name;
set @start_date := '2022-01-01';
SET @end_date := '2022-01-05';

WITH RECURSIVE
DateRange(DateData) AS
(
SELECT @start_date
UNION ALL
SELECT DATE_ADD(DateData, INTERVAL 1 DAY) FROM DateRange WHERE DateData < @end_date
)
SELECT DateData FROM DateRange;

--

--

--

A Programmer, Data Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Turn Ideas into Reality

Metaverse “JRWorld”, like the movie “Ready Player One” Apply body tracking technology.

IOCaste Physics Routine

These 5 Words Destroyed a Car Brand

{UPDATE} بلياردو برو الفاتحون اونلاين Hack Free Resources Generator

Notes FROM Amazon Innovate Online Conference — Global Edition 2019 Part 4

Tower of Hanoi in Python

Dynamic SQL and Embedded SQL

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
fish~~

fish~~

A Programmer, Data Engineer

More from Medium

Learning Vulkan without prior experience with Graphics APIs

Parse JSON In Canvas App using Regex

From Excel Sheet to Postman Request

Learning note for Docker (1) — How to use insecure docker registry?