Created
February 13, 2022 10:01
-
-
Save dorianmariecom/5ca61a113688bfd6889b0900ab8d4b39 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 | |
first_name | |
FROM | |
users | |
LEFT JOIN messages received_messages ON received_messages.from_id = 1 | |
AND received_messages.to_id = users.id | |
LEFT JOIN messages sent_messages ON sent_messages.from_id = users.id | |
AND sent_messages.to_id = 1 | |
WHERE | |
received_messages.id IS NOT NULL | |
OR sent_messages.id IS NOT NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment