SQL Left Join
A LEFT JOIN
(or LEFT OUTER JOIN
) returns all rows from the left table and the matching rows from the right table. If there are no matches, NULL values are returned for the columns from the right table.
Example: Using LEFT JOIN
SELECT FreedomFighters.Name, Events.EventName, Events.EventDate
FROM FreedomFighters
LEFT JOIN Events ON FreedomFighters.FighterID = Events.FighterID;
Output:
Name | EventName | EventDate |
---|---|---|
Mahatma Gandhi | Dandi March | 1930-03-12 |
Subhas Chandra Bose | INA Formation | 1942-10-21 |
Bhagat Singh | Lahore Protest | 1929-12-19 |
Rani Lakshmi Bai | Battle of Jhansi | 1858-03-23 |