Home › Forums › Help needed › how to nest the tags › Reply To: how to nest the tags
Store tags in a way that allows for nesting:
WITH RECURSIVE tag_hierarchy AS (
SELECT id, name, parent_id
FROM tags
WHERE parent_id IS NULL
UNION ALL
SELECT t.id, t.name, t.parent_id
FROM tags t
INNER JOIN tag_hierarchy th ON th.id = t.parent_id
)
SELECT * FROM tag_hierarchy;
SELECT id, name, parent_id
FROM tags
WHERE parent_id IS NULL
UNION ALL
SELECT t.id, t.name, t.parent_id
FROM tags t
INNER JOIN tag_hierarchy th ON th.id = t.parent_id
)
SELECT * FROM tag_hierarchy;
snow rider 3d is fantastic!