Hi all,
I have a table that holds folder information (parent and children, identified by parentid). There's a different table for file information and a many-many relationship between them. This new table holds folder_id and file_id to keep track which files belong to which folders. E.g
Folder_ID Folder_Name ParentId
1 Top Folder 0
2 Sub Folder 1
File_Id FileName
1 File1
Id File_Id Folder_Id
1 1 2
Now the problem I am having is, that if a user selects any top folder (folder_Id:1 in this case), I have to list all the files that belong to that folder heirarchy (which includes children, subchildren etc). In the above case, selecting folder_id:1, would return back File_id:1. What kind of query I could use here?
The second issue is very much related to the above one, users can search for files based on name (and some other criteria) and I have to display the top folder that the files brought up by the search fall in. Like, if I search for '%File%' in the filename field, I should get back 'Top Folder' (since its the top most folder in the heirarchy under which the file falls). I am not sure how can I perform such search.
Would appreciate all help!
Cheers!
I have a table that holds folder information (parent and children, identified by parentid). There's a different table for file information and a many-many relationship between them. This new table holds folder_id and file_id to keep track which files belong to which folders. E.g
Folder_ID Folder_Name ParentId
1 Top Folder 0
2 Sub Folder 1
File_Id FileName
1 File1
Id File_Id Folder_Id
1 1 2
Now the problem I am having is, that if a user selects any top folder (folder_Id:1 in this case), I have to list all the files that belong to that folder heirarchy (which includes children, subchildren etc). In the above case, selecting folder_id:1, would return back File_id:1. What kind of query I could use here?
The second issue is very much related to the above one, users can search for files based on name (and some other criteria) and I have to display the top folder that the files brought up by the search fall in. Like, if I search for '%File%' in the filename field, I should get back 'Top Folder' (since its the top most folder in the heirarchy under which the file falls). I am not sure how can I perform such search.
Would appreciate all help!
Cheers!