github.com/10ego/gthp@v0.0.0-20241025155251-e1514fa71fbb/internal/database/queries/query.sql (about)

     1  -- name: GetParentOrg :many
     2  WITH RECURSIVE orgs_q as
     3  (
     4  	select id, name, parent_id
     5  	from organizations o
     6  	where o.name = $1 
     7  	UNION ALL
     8  select p.id, p.name, p.parent_id
     9  from organizations p
    10  INNER JOIN orgs_q q ON o.id = q.parent_id 
    11  )
    12  select * from orgs_q;