My database structure is like this:
Members table
|id|username|...
Messages table
|id|fromId|toId|content
In the messages table id refers to the message ID, in the members it refers to the user id (which is the same Id that is in fromId and toId). I want to do a join query FROM messages WHERE id=SOME_MESSAGE_ID that pulls the following result set
|id(message id)|fromId|fromUsername(username that corresponds to fromId)|toId|toUsername(username that corresponds to toId)|content
Any help would be appreciated.
Join the members table twice but using different aliases: