"pedro mpa" <[EMAIL PROTECTED]> wrote on 10/24/2005 06:32:48 PM:

> Hi!
> 
> I need help on implementing a query that performs a search for items 
under
> nested categories. An example is on ebay search where you can restrict 
your
> search by selecting a subcategory and you only get items under that
> category/subcategories.
> Do I have to first get a list of all subcategories under the selected
> category and then loop OR's or is there a better way?
> 
> Some example tables:
> 
> | id | pid | category |
>   1     0    cat1
>   2     0    cat2
>   3     1    cat3
>   4     1    cat4
>   5     2    cat5
> 
> | id | id_category | item |
>   1    3             item1
>   2    4             item2
>   3    5             item3
> 
> 
> (Running Mysql 4.1.9 and PHP 5.0.4).
> Thanks in advance.
> Apologies for my bad English.
> Pedro.
> 

I think there is a better way to store your information which will ease 
your searching problems. Please read these articles and see if you get any 
ideas: 
http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
http://www.sitepoint.com/article/hierarchical-data-database/2

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Reply via email to