Login using Social Account
     Continue with GoogleLogin using your credentials
Self-Join means joining of a table with itself.
We will create a self-join table based on 'emp_<
So, if we want to display employee name followed by employee's manager name in same rows, then self-join has to be used.
%%sql
select e.empid, concat(e.empfname,' ',e.emplname) "employee", e.mgrempid, concat(m.empfname,' ',m.emplname) "manager"
from emp_<<your lab username>> e, emp_<<your lab username>> m
where e.mgrempid = m.empid
order by 1,2
;
All the above joins are called Inner joins where there will be output only if columns in WHERE clause have matching data in both tables. In above output, empid 1 is not displayed because it doesn't have any manager.
%%sql
select * from emp_<<your lab username>> where empid = 1;
So, how to display record for that employee sans manager detail? We could use Outer Joins, about which we will learn next!
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
No hints are availble for this assesment
Answer is not availble for this assesment
Loading comments...