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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Searching Tree Structures

Author  Topic 

sp00ky
Starting Member

1 Post

Posted - 2003-10-13 : 03:24:56
I have implemented in my db a similar structure. Now what seems to be the problems is the fact that I need to search such a structure for a certain item. The user enters the name of a certain, lets say, product and a certain domain. The given product must be searched inside the given domain and all it's subdomains. This would not be a problem if pagination of the results is not required. But it is. So I need to do the whole search in one query so that only one result is generated (which I can use to generate the pages)... So, how is the syntax for the SELECT query for such a thing? Is it even posible to do this search in one query?

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-10-13 : 07:39:36
What is a "similar structure"?

Jay White
{0}
Go to Top of Page

Lavos
Posting Yak Master

200 Posts

Posted - 2003-10-13 : 08:04:01
I think he means a Trie structure. It's pretty similar to a tree structure, but it's spelled different.


But seriously, using my mind powers to read your database schema I'm guessing that you are storing parent id for each nodes. In that case, then yeah it's impossible to do it reasonably in one query. If you look up nested sets and implement those instead, then you could do it pretty easily in one query. Of course, I'm guessing, but next time you should post at least a skeleton of the table structure (and if you really want help, post data, and expected results.)

----------------------
"O Theos mou! Echo ten labrida en te mou kephale!"

"Where theres a will, theres a kludge." - Ken Henderson
Go to Top of Page
   

- Advertisement -