I am currently developing an application that should store a hierarchy of files (folders and files do not differ) in the database. The following table has been created for this:
tbl_files
| id | name | parent |
The fields of the parent field are external to tbl_files. The main directory has id root. Now I want to get the file path until the root directory is reached. I thought about this with recursive SQL-Query, but I don’t know how to “return” the path from the database.
Is a recursive query ok or is it bad practice? And how do I "generate" a path with this query?
source
share