parent
5063227960
commit
631e156166
@ -0,0 +1,13 @@
|
||||
```sql
|
||||
WITH RECURSIVE parent_path (id, title, description, path) AS
|
||||
(
|
||||
SELECT id, title, description, title as path
|
||||
FROM items
|
||||
WHERE parent_id IS NULL
|
||||
UNION ALL
|
||||
SELECT i.id, i.title, i.description, CONCAT(ip.path, ' > ', i.title)
|
||||
FROM parent_path AS ip JOIN items AS i
|
||||
ON ip.id = i.parent_id
|
||||
)
|
||||
SELECT * FROM parent_path WHERE id = 38;
|
||||
```
|
||||
Loading…
Reference in new issue