MySQL Forums
Forum List  »  PHP

Re: Trying to doing it all in SQL
Posted by: Felix Geerinckx
Date: December 29, 2005 09:58AM

Edward Perry wrote:

> I have figured out how to eliminate one query with a join but then I still have to do a lookup for
> the other users information.

You need to join the user_bio table twice, as in

SELECT
CONCAT_WS(' ', fu.user_Lname, fu.user_Fname) AS from_user,
CONCAT_WS(' ', tu.user_Lname, tu.user_Lname) AS to_user,
chat.message
FROM chat
JOIN user_bio fu ON fu.id = chat.from_userid
JOIN user_bio tu ON tu.id = chat.to_userid
WHERE
chat.from_userid="$uid" or chat.to_userid="$userid" ;

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
December 29, 2005 09:33AM
Re: Trying to doing it all in SQL
December 29, 2005 09:58AM
December 29, 2005 11:34AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.