The RIGHT 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 Right Table only i.e. Table B.
RIGHT JOIN : keyword used for RIGHT JOIN, in order to fetch all the matching records from both the table and non matching data from Right 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 34.1. LEFT TABLE PERSONS
Figure 34.2. RIGHT TABLE SALARY
The following SQL statement selects all records from Salary Table (Right table) with matching records from Persons table (Left Table).
Note: A Right join returns NULL from left side in case of no matching join.
Want More SQL Deep Dives