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
Show parent comment
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
View all comments
Show parent comment
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:
1
2
3
4
5
Table B contains:
3
5
7
9
11
JOIN (inner join) returns:
3-3
5-5
LEFT JOIN returns
1 - NULL
2 - NULL
3 - 3
4 - NULL
5 - 5
RIGHT JOIN returns
3 - 3
5 - 5
NULL - 7
NULL - 9
NULL - 11