?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


C# Help

?
?MySQL Tree Search
Author:??(81.196.249.---)
Date:???10-11-03 10:15

Hi. As this problem is bugging me for some time now I'll get directly to the point:
Inside a database I have two tables, with the following structures:
-- product table --
id int(11) unsigned NOT NULL auto_increment
name text NOT NULL
key_id int(11) unsigned NOT NULL default '0'
PRIMARY KEY (id), KEY id (id) TYPE=MyISAM
--domains table --
id int(11) unsigned NOT NULL auto_increment
name text NOT NULL
pid int(11) unsigned NOT NULL default '0'
PRIMARY KEY (id), KEY id (id,pid) TYPE=MyISAM
The domains table simulates a file-tree by entering in the pid-field the id of the parent domain. pid comes from prarent-id. The number of levels of this 'tree' is limited to 3. In the products table, the key_id field stores the ID of the domain under which the product is entered. The problem is that I need to create a SELECT query that searches a given domain and it's subdomains for a product. A single SELECT, that is. I managed to search and return results but using multiple selects. The reason why I need a single select is that the results have to be paginated and I need one result resource only. In short I requiere the query for a search inside a tree-structure for a given term. The problem needs to be fixed urgently! Thanks to all those who will respond!

?Topics Author? Date
?MySQL Tree Search??new
Spooky 10-11-03 10:15?
?Re: MySQL Tree Search??new
bastien 10-11-03 11:22?
?Re: MySQL Tree Search??new
Spooky 10-16-03 01:18?
Go to Top??|??Go to Topic??|??Flat View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??wrote: > > Hi. As this problem is bugging me for some time now I'll get > directly to the point: > Inside a database I have two tables, with the following > structures: > -- product table -- > id int(11) unsigned NOT NULL auto_increment > name text NOT NULL > key_id int(11) unsigned NOT NULL default '0' > PRIMARY KEY (id), KEY id (id) TYPE=MyISAM > --domains table -- > id int(11) unsigned NOT NULL auto_increment > name text NOT NULL > pid int(11) unsigned NOT NULL default '0' > PRIMARY KEY (id), KEY id (id,pid) TYPE=MyISAM > The domains table simulates a file-tree by entering in the > pid-field the id of the parent domain. pid comes from > prarent-id. The number of levels of this 'tree' is limited to > 3. In the products table, the key_id field stores the ID of > the domain under which the product is entered. The problem is > that I need to create a SELECT query that searches a given > domain and it's subdomains for a product. A single SELECT, > that is. I managed to search and return results but using > multiple selects. The reason why I need a single select is > that the results have to be paginated and I need one result > resource only. In short I requiere the query for a search > inside a tree-structure for a given term. The problem needs > to be fixed urgently! Thanks to all those who will respond! ">??

Provided By
Phorum