sql

My Note

sql
with recursive cte_name as (
    cte_query_definition (the anchor member)
    union all
    cte_query_definition (the recursive member)
)
select * from cte_name;
sql
with recursive managers as (
    select employee_id, last_name, reports_to
    from employees
    where reports_to is null
    union all
    select e.employee_id, e.last_name, e.reports_to
    from employees as e join managers m
    on e.reports_to = m.employee_id
)
select * from managers;