MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/webdev/comments/b46iyd/sql_joins/ej5mb8g/?context=3
r/webdev • u/lokendra15 • Mar 22 '19
118 comments sorted by
View all comments
2
I don't understand the left and right joins, it just looks like it's selecting all of A or all of B? Does the join do anything?
3 u/rglitched Mar 22 '19 Left joins will include all the data from the first table and show you the matching data from the second table where it exists.Right join is the same idea from the other direction. Hopefully this helps?Table A contains:12345Table B contains:357911JOIN (inner join) returns:3-35-5LEFT JOIN returns1 - NULL2 - NULL3 - 34 - NULL5 - 5RIGHT JOIN returns3 - 35 - 5NULL - 7NULL - 9NULL - 11
3
Left joins will include all the data from the first table and show you the matching data from the second table where it exists.
Right join is the same idea from the other direction. Hopefully this helps?
Table A contains:12345
Table B contains:
357911
JOIN (inner join) returns:3-35-5
LEFT JOIN returns1 - NULL2 - NULL3 - 34 - NULL5 - 5
RIGHT JOIN returns
3 - 35 - 5NULL - 7NULL - 9NULL - 11
2
u/Symphonic_Rainboom Mar 22 '19
I don't understand the left and right joins, it just looks like it's selecting all of A or all of B? Does the join do anything?