You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

324 B

WITH RECURSIVE hierarcy (id, title, description, parent_id) AS
(
  SELECT id, title, description, parent_id
    FROM items
    WHERE id = 38
  UNION ALL
  SELECT items.id, items.title, items.description, items.parent_id
    FROM hierarcy JOIN items
      ON hierarcy.parent_id = items.id
)
SELECT * FROM hierarcy;