SQL Right Join - Right Join in SQL
SQL Right JOIN
- The RIGHT JOIN keyword retrieves all records from the right table (table2) and the corresponding records from the left table (table1). If there is no match, the result includes 0 records from the left side.
Syntax
SELECT column_name(s) FROM table1; RIGHT JOIN table2; ON table1.column_name = table2.column_name;
Database
- Here is a portion from the "Wikitechy" table:
![table -Wikitechy](https://wikitechy.com/cdn/tutorials/sql/table-wikitechy.jpg)
- Here is an excerpt from the " Student Detail " table:
![table-student-details](https://wikitechy.com/cdn/tutorials/sql/table-student-details.jpg)
Example
SELECT tbl_Student_Detail.Student_Id, tbl_Wikitechy.Mark, tbl_Wikitechy.Age FROM tbl_Student_Detail RIGHT JOIN tbl_Wikitechy ON tbl_Student_Detail.Student_Id = tbl_Wikitechy.Student_Id ORDER BY tbl_Student_Detail.Student_Id;
Output
![sql-right-join](https://wikitechy.com/cdn/tutorials/sql/sql-right-join.png)