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

  • Here is an excerpt from the " Student Detail " table:
table-student-details

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


Related Searches to SQL Right Join - Right Join in SQL