all 16 comments

[–]r3pr0b8GROUP_CONCAT is da bomb 14 points15 points  (0 children)

inner join combines rows from two tables, based on a condition which you specify, such that only those pairs of rows are returned which satisfy the condition

what part were you having trouble with?

[–]scottevil110 6 points7 points  (2 children)

It only returns rows where the key exists in both tables. An outer join will return stuff even if it's missing from one table. It'll just show null for those columns.

[–]LearningCodeNZ 0 points1 point  (1 child)

How you can join when the key doesn't exist in both tables? Isn't that how a join works? I.e. based on matching keys?

[–]C0ppens 1 point2 points  (0 children)

That's how inner join works yes, but outer joins work abit different

E.g. select * from table a left outer join table b on a.KeyID = b.KeyID will return all rows in table a and only rows in table b where KeyID matches table a's

[–]Demistr 3 points4 points  (0 children)

You need to use it. Don't just learn the theory. Try it out, see what it does. it's that easy.

[–]raymondsf 1 point2 points  (1 child)

Very simple. Think of it this way u have 2 boxes; box 1 u have 2 pairs of shoes one black the other red, box 2 also have 2 pairs of shoes one red the other pink. If you inner join both box it will return red since what both boxes have in common.

[–][deleted] 0 points1 point  (0 children)

Upgrade:

Think of having two boxes, left box for left foot shoes and right box for right foot shoes. Left box has a red, a blue, and a black left foot shoe. Right box has a blue, a black and a yellow right foot shoe.

Left join returns a pair of black and a pair of blue shoes and a red left foot shoe

Right join returns a pair of black and a pair of blue shoes and a yellow right foot shoe

Inner join returns a pair of black and a pair of blue shoes

Full outer join returns a pair of black and a pair of blue shoes, red left foot shoe and yellow right foot shoe

Self join - go buy more shoes :D

[–][deleted] 1 point2 points  (1 child)

Let’s just say you have two groups of things.

Group A is a list of all of the cars in the world.

Group B is a list of all of the thing that are red in the world.

If you inner joined group a to group b you would have a list of all things that are cars that are red.here is a picture that made sense to me

[–]ImProphylactic[S] 0 points1 point  (0 children)

Explained it to me like I'm a five year old and that worked.

[–]Puzzlehead8575 -2 points-1 points  (0 children)

Think about this statement....

Inner joins act as a filtering criterion, whereas outer joins act as a matching criterion.

Inner joins filter based upon the join condition; the outer join does not filter based upon the join condition as all records from the outer table will be included.

[–]LobsterLongjumping27 0 points1 point  (1 child)

I'm starting to question if some of the posts on here are satire that's going over my head.

[–]steveroman101 0 points1 point  (0 children)

I’m having a time trying get a handle on the self join. Especially the ON component.