Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left

  Apply Now

SQL Tutorial

25 / 68

Outer Joins

Outer joins are for finding records that may not have a match in the other table. You specify which side of the join is allowed to have a missing record.

left outer join (or just left join) -> Table on right side can have missing records
right outer join (or just right join) -> Table on left side can have missing records

select
e.empid
, concat(e.empfname,' ',e.emplname) "employee"
, e.mgrempid
, concat(m.empfname,' ',m.emplname) "manager"
from emp e left outer join emp m
on e.mgrempid = m.empid
order by 1,2
;

In above example, empid 1 doesn't have manager id, so manager name will be displayed as NULL rather than not displaying row for empid 1 at all.


No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...