Wednesday, January 20, 2016

SQL JOIN: Display Records With or Without Match on The Other Table

There will be cases where you want to join two (2) table and display records that has match or even without match on the other table.

Table

STUDENT



GRADES








Refer on the table above. 
Query
SELECT * FROM student left join grade on student.stud_id=grade.stud_id

If you want to display all students even without grades, then you can use SQL LEFT JOIN or RIGHT JOIN.  The LEFT JOIN will display all records on the left table even without match on the right table. The RIGHT JOIN will display all records on the right table even without a match on the left table.

Output


SQL JOIN: Display Records With or Without Match on The Other Table

SQL JOIN: Display Records With or Without Match on The Other Table Rating: 4.5 Diposkan Oleh: Emoblazz

0 comments:

Post a Comment