Joining same table twice

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

 



i apologize if its against the rules to post mysql questions here, though im
using php to query the db
so...

i have a table with three integers.

[table post]
postuserid | replyuserid | parentid
----------------------------------

i do a left join on table user to get the username that postuserid belongs
to, but i also need to get the username on the same table 'user' of
replyuserid as well if parentid isn't null. can this be done with a single
query?

this is what i have:

mysql_query("
SELECT post.postuserid, post.replyuserid, post.parentid, user.username AS
uname FROM post
LEFT JOIN user ON(user.userid = post.postuserid) ORDER BY id");

that gets me the username of postuserid, but what about replyuserid, how i
get that username?

thanks for any help.

-- 
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