Joining same table twice

From: Date: Sat, 11 Dec 2004 22:50:14 +0000
Subject: Joining same table twice
Groups: php.general 
Request: Send a blank email to php-general+get-204073@lists.php.net to get a copy of this message
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.

« previous php.general (#204073) next »