SQL Left Join

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


SELECT column_name(s) FROM table1
LEFT 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


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

StudentID StudentName Fees
15 Rahul 800
16 Karan 800
17 Ajay 800
18 Rocky Null

Back To Top