Skip to content

Instantly share code, notes, and snippets.

@sigma23
Created October 22, 2018 21:26
Show Gist options
  • Save sigma23/0f5e2b133255b0fe2d87cacebbb202d2 to your computer and use it in GitHub Desktop.
Save sigma23/0f5e2b133255b0fe2d87cacebbb202d2 to your computer and use it in GitHub Desktop.
To do a join in sql and also keep null values
select B.*, A.*
from B
left outer join A ON
(A.[id1] = B.[id1] or (coalesce(A.[id1],B.[id1]) is null))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment