Database Administration Fundamentals (SF17SQL1001) – Day 6

Last night, aside from INNER JOIN that allows us to retrieve all data shared by table1 and table2

SELECT field1, field2 ...
FROM table1         -- all data related to table2
INNNER JOIN table2  -- all data related to table1
  ON table1.fieldX = table2.fieldX;

we covered LEFT JOIN that allows us to retrieve data from table1 and any related data from table2

SELECT field1, field2 ...
FROM table1         -- all data
LEFT JOIN table2    -- corresponding data related to table1
  ON table1.fieldX = table2.fieldX;

and RIGHT JOIN that allows us to retrieve data from table2 and any related data from table1.

SELECT field1, field2 ...
FROM table1         -- corresponding data related to table2
RIGHT JOIN table2   -- all data
  ON table1.fieldX = table2.fieldX;

Download the class notes for day 6.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.