category and sub category traversal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Google for "SELF JOIN"

You also may want to just put the parent_id in the category table, rather than a second table.

Your query would then look like this:

select parent.tid, child.tid
from term_data as parent, term_data as child
where child.parent_id = parent.tid
and child.vid = 16
order by weight, name

WARNING:
If term_data is a LARGE table, this query could become problematic.

You'll need an index on (tid, vid, weight, name), I think.

Follow-up with more questions to the MySQL (or other SQL) mailing list please, as there's no actual PHP in this question.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux