SQL LEFT JOIN KeywordThe LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2). SQL LEFT JOIN Syntax
PS: In some databases LEFT JOIN is called LEFT OUTER JOIN. SQL LEFT JOIN ExampleThe "Persons" table:
The "Orders" table:
Now we want to list all the persons and their orders - if any, from the tables above. We use the following SELECT statement:
The result-set will look like this:
The LEFT JOIN keyword returns all the rows from the left table (Persons), even if there are no matches in the right table (Orders). |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||