postgreSQL ltree工具獲取上下級

select * from departments

/*
  
查詢子級部門 path <@ '' 查詢上級部門 path @>
  path: 部門id用'.'鏈接
*/
select
id,name,path,parent_id from departments where path <@ cast('NE*********Pc.NE*********Pd.NE*********Ra' as ltree)

相關文章
相關標籤/搜索