In right join type of MySQL, all records from the right table, the one after the join clause are fetched. While only the matched rows from the left table are returned. As using the right join, the values in empty rows of the left table are shown as Null values.
This is how right join is used:
Select * from table_name1
right Join table_name2 ON table_name1.common_field = table_name2.common_field
For our example, we will use the departmental store scenario. Consider a departmental store database tables:
The MySQL right join query:
1
|
select * from tbl_employee TE right join tbl_customers_orders TC ON TE.emp_id=TC.emp_id
|
In above query’s output, you can see all records are fetched from the right table.
Leave A Comment?