Table_Users
id username
1 Jack
2 Marine
3 Katie
4 Hennry
Table_Messages
id to_id from_id Messages
1 2 3 Hello
2 3 2 Hi
Need a single query which can return a Message, To Name and From Name
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to join the table
userson tablemessagestwice since you need to get the equivalent names fortoandfromusers.See SQLFiddle Demo