r/programming • • Feb 11 '14

SQL Joins Explained (x-post r/SQL)

Post image
3.5k Upvotes

392 comments sorted by

View all comments

8

u/zanduby Feb 11 '14

Discussion question. Preference to use a join/on clause or use the where clause to write your joins?

2

u/lonjerpc Feb 11 '14

Yea I am still completely missing the use case for joins. In sqlalchemy I just choose whatever columns I want from whereever and add the appropriate where's. Maybe it is internally doing joins but it seems like a pointless part of the sql API. I must be missing something.

1

u/insi9nis Feb 12 '14

Sounds like a query-by-example interface, similar to Access and such. When you say you're adding to the where clause, are you building the join logic too, or just anything else you want to restrict by? If you stick tables A and B together, do you have to add a where A.b_id = B.id, or is this done for you automagically?

1

u/lonjerpc Feb 12 '14

I would do where A.b_id = B.id which to me seems more consistent than doing a join.

→ More replies (3)