Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sql query help
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

23 Posts

Posted - 05/11/2007 :  10:17:40  Show Profile  Reply with Quote
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!

  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000