[SQL]with m as (
select t.department_id, t.department_name, t.parent_id from t_seller_department t where t.department_id = 1
union all
select t.department_id, t.department_name, t.parent_id from t,m where t.parent_id = m.department_id
)
select * from m
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'm as (
select t.department_id, t.department_name, t.parent_id from t_seller' at line 1
-- 把 100 改成你的 departID
with m as (
select t.id, t.name, t.pid from t where id = 100
union all
select t.id, t.name, t.pid from t,m where t.pid = m.id
)
select * from m