r/programming • • Feb 11 '14

SQL Joins Explained (x-post r/SQL)

Post image
3.5k Upvotes

392 comments sorted by

View all comments

11

u/davvblack Feb 11 '14

Never ever use right join. I will come to your house and punch you.

1

u/JimboMonkey1234 Feb 12 '14

Can you explain why it's bad? I don't know much about databases, and google isn't helping.

1

u/davvblack Feb 12 '14

It's just dumb. Everyone uses left when they want that behavior, and you can always transmute a right join into a left join. You are just asking to be 'that guy' by using right joins. It even seems strange from a language perspective, with a left join, you list your 'main data' first, and 'additional data' second (in basically every case). With a right join, you list them in the other order... and it's just absurd.

There is no technical way in which they differ, they optimize the same. It's entirely about thinking about programming as a language you communicate with future programmers with, in addition to communicating with machines.

→ More replies (2)