My table structure:
id | name | parent_id
0 | "name0" | NULL
1 | "name1" | 0
2 | "name2" | 1
...
I need something like:
id | full_path
2 | "name0|name1|name2"
2
is specified by user; path's length is unknown. How can do produce something like this with MySQL?
select id,(select GROUP_CONCAT(CONCAT(name) SEPARATOR '|') as full_path from test )
full_path from test where id=2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.