Last active
September 14, 2017 16:26
-
-
Save nathanpeck/f7b5daf264c12d3a9dd8e15e390cd028 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
m.id id, | |
m.user `user`, | |
u.name name, | |
u.avatar avatar, | |
m.text `text`, | |
m.when `when` | |
FROM messages m | |
INNER JOIN ( | |
SELECT `from`, `to` | |
FROM `friends` | |
WHERE `from`=1 | |
) f | |
ON m.user = f.to | |
INNER JOIN users u on m.user = u.id | |
ORDER BY m.when DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment