SQL RIGHT JOIN
The RIGHT JOIN returns all rows from the table B, whether or not there is a match with table A.
SQL Right Join syntax
SELECT column_name(s)
FROM A_table RIGHT JOIN B_table
ON A_table.column_name = B_table.column_name;
Training_Course
ID | NAME | DURATION | PRICE |
---|
1 | SQL | 5 | 200 |
2 | T-SQL | 7 | 700 |
3 | MySQL | 5 | 600 |
4 | PL/SQL | 7 | 800 |
5 | PostgreSQL | 6 | 500 |
Certifications
ID | NAME | PRICE | ID_TC |
---|
1 | PostgreSQL certification | 800 | 5 |
2 | SQL certification | 350 | 1 |
3 | T-SQL certification | 1000 | 2 |
4 | Oracle-SQL certification | 2000 | NULL |
Example
SELECT c.ID,c.NAME,c.PRICE
FROM Training_Course t RIGHT JOIN Certifications c
ON t.ID = c.ID_TC ;
Results
ID | NAME | PRICE |
---|
1 | PostgreSQL certification | 800 |
2 | SQL certification | 350 |
3 | T-SQL certification | 1000 |
4 | Oracle-SQL certification | 2000 |