----- Original Message ----- From: "Michelle de Beer" <[EMAIL PROTECTED]>
> I believe this question is solved by a join, but I > haven't really got a hang of it. > > My table: > -------------------------------------- > | uid | rootid | parentid | name | > -------------------------------------- > | 1 | 0 | 0 | name1 | > | 2 | 1 | 1 | name2 | > | 3 | 1 | 2 | name3 | > | 4 | 1 | 3 | name4 | > | 5 | 1 | 2 | name5 | > ... > > How do I get this (WHERE uid=5): > ------------------------------------------ > | rootid_name | parentid_name | name | > ------------------------------------------ > | name1 | name2 | name5 | > ------------------------------------------ > Here you go. select a.name, b.name, c.name from yourtable as a, yourtable as b, yourtable as c where a.uid=c.rootid and b.uid=c.parentid and uid=5; or, as left joins: select a.name, b.name, c.name from yourtable as c left join yourtable as a on a.uid=c.rootid left join yourtable as b on b.uid=c.parentid where uid=5; Ryan sql to the hizzo query to the hizza --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php