Skip to content

Instantly share code, notes, and snippets.

@mattm

mattm/join.sql Secret

Created November 12, 2018 17:13
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/1c05b3f37bc8d62d76dc079d2c375a68 to your computer and use it in GitHub Desktop.
Save mattm/1c05b3f37bc8d62d76dc079d2c375a68 to your computer and use it in GitHub Desktop.
INNER vs LEFT JOIN
# Good: INNER JOIN
...
SELECT a.email AS email, a.created_at AS expressed_interest_at
FROM helpscout.conversation AS a
INNER JOIN helpscout.conversation AS b ON a.id = b.conversation_id
WHERE b.conversation_id = 'beacon-interest'
...
# Okay: LEFT JOIN
...
select
c.email,
c.created_at as expressed_interest_at
from hubspot.conversation c
left join hubspot.conversation_tag t on c.id = t.conversation_id
where t.tag = 'beacon-interest'
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment