Skip to content

Instantly share code, notes, and snippets.

@workze
Last active April 29, 2020 02:13
Show Gist options
  • Save workze/c40ae8cc421f954e49b5ad8a9be698a9 to your computer and use it in GitHub Desktop.
Save workze/c40ae8cc421f954e49b5ad8a9be698a9 to your computer and use it in GitHub Desktop.
mysql cte with
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