Hello Joseph, Thursday, December 05, 2002, 8:39:18 PM, you wrote: NJ> Victoria,
NJ> I am trying to get the hang of this also. In your statement below you NJ> show, what appears to me, two tables, mytest ( I see this one ) and t1. NJ> Where did table t1 come from? Could you explain your sql a little more NJ> if that would not be to much of a problem? Thank you for you patience. 'mytable' - ia a real table. t1, t2, and t3 are aliases. I use a self join - join 'mytable' with the 'mytable' on the conditions t1.rootid=t2.uid to get the name for 'rootid' and then one more self join to get the name for 'parentid'. NJ> -joseph NJ> -----Original Message----- NJ> From: Victoria Reznichenko [mailto:[EMAIL PROTECTED]] NJ> Sent: Thursday, December 05, 2002 9:01 AM NJ> To: [EMAIL PROTECTED] NJ> Subject: re: Join-question NJ> Michelle, NJ> Thursday, December 05, 2002, 5:46:03 PM, you wrote: MdB>> I believe this question is solved by a join, but I MdB>> haven't really got a hang of it. MdB>> My table: MdB>> -------------------------------------- MdB>> | uid | rootid | parentid | name | MdB>> -------------------------------------- MdB>> | 1 | 0 | 0 | name1 | MdB>> | 2 | 1 | 1 | name2 | MdB>> | 3 | 1 | 2 | name3 | MdB>> | 4 | 1 | 3 | name4 | MdB>> | 5 | 1 | 2 | name5 | MdB>> ... MdB>> How do I get this (WHERE uid=5): MdB>> ------------------------------------------ MdB>> | rootid_name | parentid_name | name | MdB>> ------------------------------------------ MdB>> | name1 | name2 | name5 | MdB>> ------------------------------------------ MdB>> If you need more info, please tell me. NJ> Yes, JOIN is what you need. NJ> Something like that: mysql>> SELECT t1.uid, t1.name, t2.name, t3.name ->> FROM mytest t1 ->> LEFT JOIN mytest t2 ON t1.rootid=t2.uid ->> LEFT JOIN mytest t3 ON t1.parentid=t3.uid ->> WHERE t1.uid=5; NJ> +------+-------+-------+-------+ NJ> | uid | name | name | name | NJ> +------+-------+-------+-------+ NJ> | 5 | name5 | name1 | name2 | NJ> +------+-------+-------+-------+ NJ> 1 row in set (0.00 sec) -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Victoria Reznichenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com --------------------------------------------------------------------- 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