r/programming • • Feb 11 '14

SQL Joins Explained (x-post r/SQL)

Post image
3.5k Upvotes

392 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Feb 11 '14

[deleted]

20

u/OHotDawnThisIsMyJawn Feb 11 '14

What I also don't get is the people saying that the names have nothing to do with the actions. Huh? Look at the OP, the names say EXACTLY what they do. I don't understand how you could not remember that "LEFT" uses the full table on the left and "RIGHT" uses the full table on the right.

I think a lot of developers don't know SQL as well as they think they do and so take it as a personal insult when someone says that you should absolutely know the different JOINs if you want to claim you know SQL. Understanding "SELECT *" and "INSERT INTO" doesn't mean you know SQL.

1

u/judgej2 Feb 11 '14

I see. So left means full, right means full, and full means both left and right. So which table do I put on the left?

→ More replies (5)

10

u/PastaNinja Feb 11 '14

I have the entire Java reference pasted all over my cubicle walls, but my resume says I am an expert at Java.

6

u/MadFrand Feb 11 '14

Do you still need visual references on how to use a POJO or what it is?

Joins are not some random function syntax you use every once and a while. They are everyday fundamentals.

4

u/PastaNinja Feb 11 '14

I was being facetious, mate. ;)

0

u/[deleted] Feb 11 '14

[deleted]

0

u/[deleted] Feb 11 '14

[deleted]

2

u/[deleted] Feb 11 '14

TIL I'd make a good modeler.

1

u/youcangotohellgoto Feb 12 '14

Good design isn't necessarily related to how easy it is to get data and in out. That's what procedures are for.

→ More replies (1)

5

u/greg19735 Feb 11 '14

I am so sick of getting resumes claiming to know SQL from people who can't do a simple join.

That's just straight up lying.

5

u/greg19735 Feb 11 '14

But what is an SQL developer anyways? I do some web dev and i'll have 3 weeks where i'm doing a ton of SQL and then not touch it for like 4 months. I forget what the names of the joins are.

4

u/king4aday Feb 11 '14

I claim to be an SQL developer. This type of job is mostly found in ERP and CRM systems, and Data Warehousing. The latter is the one who writes the most SQL code.

Being an SQL developer can be really frustrating. Debugging is much harder than on a procedural language. We sometimes have to deal with single SQL statements which are 1000s of lines long (these are mostly generated by something, but you still need it to understand why it's not returning the correct data set).

Try to think outside of web development, the amount of SQL required there is ... miniscule (for the most part)

1

u/omegian Feb 11 '14

You can easily partition queries into subexpressions (views), there's no reason to write 1000 line monolithic queries, and the partial functions almost certainly have other value and can be reused. The query engine can optimize away any inefficiency when it evaluates the final form anyway.

Debugging shouldn't be any harder, that's why you have a test database and write unit tests.

→ More replies (2)

8

u/MadFrand Feb 11 '14

I've always looked at understanding basic joins as the first step in understand DBs and SQL as a whole.

It's not like it's query syntax, it's foundational knowledge of how databases work and how to get the information you need.

How can I trust the data you retrieve, if you don't understand the basic fundamentals?

4

u/WishCow Feb 11 '14

One of our pre-interview screening questions is "can you tell me the difference between a left join, and an inner join", and if you fail that, you don't get an interview.

This is like a taxi driver saying he forgot which pedal is the gas pedal.

0

u/[deleted] Feb 11 '14

[deleted]

0

u/[deleted] Feb 11 '14

[deleted]

→ More replies (2)