SQL Right Join

SQL Right Join It returns all records from right table and matched columns from left table. If there is no match from left then result from left will be null.

Syntax



SELECT column_name(s) FROM table1
RIGHT JOIN table2 ON table1.column_name = table2.column_name;


Take a table Student:

StudentID StudentName City
15 Rahul Pathankot
16 Karan Pathankot
17 Ajay Pathankot
18 Rocky Pathankot


Now, Take another table Fees

FeesID StudentID StudentName Fees
1 15 Rahul 800
2 16 Karan 800
3 17 Ajay 800


Query



SELECT Fees.FeesID, Fees.Fees, Student.StudentName, FROM Fees
LEFT JOIN Student ON StudentID.Fees=StudentID.Student;



FeesID StudentName Fees
1 Rahul 800
2 Karan 800
3 Ajay 800

Back To Top