The LEFT Join condition returns values as per below rule:
All the matching data values from Table A and Table B.
All the non-matching data values from Left Table only i.e. Table A.
LEFT JOIN : keyword used for LEFT JOIN, in order to fetch all the matching records from both the table and non-matching data from Left table.
Table_name1/Table_name2 : The name of the first/second table from where you want to fetch the data
Column1Name : The name of the columns of the table based on which you want to join.
Let us consider a demo database with two tables Persons & Salary. Following is the structure of both the tables:
Figure 33.1. LEFT TABLE PERSONS
Figure 33.2. RIGHT TABLE SALARY
The following SQL statement selects all records from Persons table (Left Table) with matching records from Salary Table (Right table)
Note: A left join returns NULL in case of no matching join.
Want More SQL Deep Dives