Last active
April 29, 2020 02:13
-
-
Save workze/c40ae8cc421f954e49b5ad8a9be698a9 to your computer and use it in GitHub Desktop.
mysql cte with
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with t1 as (select * from t_table where id = 1), t2 as (select * from t1 where id = 1) | |
select * from t1, t2 | |
递归CTE | |
with recursive cte(n) as ( | |
select 1 | |
union all | |
select n+1 from cte where n < 5 | |
) | |
select * from cte; | |
--- | |
n | |
--- | |
1 | |
2 | |
3 | |
4 | |
5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment