Skip to content

Instantly share code, notes, and snippets.

@mattm
Last active November 12, 2018 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattm/075b6b5c5823cb390b19bf29dcb32b07 to your computer and use it in GitHub Desktop.
Save mattm/075b6b5c5823cb390b19bf29dcb32b07 to your computer and use it in GitHub Desktop.
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