Which SQL Join should be used?

I still don’t quite understand when I am supposed to use an INNER Join, or a Outer Join, Left or Right. What should be the approach in this? I am concerned about this because I’ve been completing the missions, and it has happened a couple of times where I am using an INNER Join but the hint and solution tell that using a LEFT join would be the best approach. Why and how?
Please help me understand this.

1 Like

For example you have two tables with the keys: A: [1, 2, 3, 5, 6, 7] and B: [1, 2, 3, 6, 7, 8, 9, 10, 11].
If you want to match the same keys in both table A and B . You use inner INNER JOIN. Here your new table with combine the following with keys [1, 2, 3, 6, 7] since they appear on both tables.

If you want to keep all information in table A, you use LEFT JOIN.

Check this stackoverflow explanation

4 Likes