Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
actuary
Starting Member
23 Posts |
Posted - 2007-05-11 : 10:17:40
|
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.gFolder_ID Folder_Name ParentId1 Top Folder 02 Sub Folder 1File_Id FileName1 File1Id File_Id Folder_Id1 1 2Now 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! |
|
|
|
|