Skip to content

Instantly share code, notes, and snippets.

@mattm

mattm/join-vs-where.sql Secret

Last active Nov 12, 2018
Embed
What would you like to do?
WHERE clause vs JOIN condition
# Good: Filtering in the WHERE clause
...
SELECT cnv.email,
cnv.created_at AS expressed_interest_at
FROM helpscout.conversation AS cnv
JOIN helpscout.conversation_tag AS ctg
ON cnv.id = ctg.conversation_id
WHERE ctg.tag = 'beacon-interest'
...
# Good: Including it in the join condition
...
select conv.email, conv.created_at as expressed_interest_at
from helpscout.conversation conv
join helpscout.conversation_tag tag
on conv.id = tag.conversation_id and tag.tag = 'beacon-interest'
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment