之前一直用Oracle,一下子换到了Sql,有些语法还真不熟悉,再次记录一下:
with t1 as ( select a.dptname,a.parentid,a.deptid,a.status,a.typecode from base_dept a where a.deptid=2 union all select d.dptname,d.parentid,d.deptid,d.status,d.typecode from base_dept d inner join base_dept c on d.parentid=c.deptid ) select * from t1