tree traverse - actually get parent_id

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

tree traverse - actually get parent_id

Post by GeXus »

I'm trying to do a select statement that will allow me to actually return the parent category_id from a tree traversal. I know that this is not typically how it's done, but I need to know the parent id for this JavaScript I want to use..

Thanks a lot!
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

something like this may work:

Code: Select all

select id
from tree
where `left` < $nodeLeft
order by `left` desc
limit 1,1
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

That simple eh.. i'll give it a try.. thanks!
Post Reply