I have this in a MySQL db:
table Message
sender_id int
recipient_id int
created datetime
[title, body, etc... omitted]
Is it possible to get from this, in a single query, a list of all the users who have been communicating with a given user with id N (meaning N appears in either sender_id
or recipient_id
), ordered by created
, including the most recent value of created
, without duplicates (no sender/recipient pairs N, M and M, N)?
I'm pretty sure the answer is No, but I'm having trouble convincing myself. Afternoon mental dullness.
If No, what's the most efficient alternative you would recommend?
EDIT: holy crap, Stack Overflow is hopping these days. 8 answers before I realize I forgot to specify that I would like to have the most-recent value of created
present along with the other user ID in each row.