Hi guys I am trying to create a query to display employee name and employee number along with their super’s name and super’s number. Listing also includes employees who don’t have any supervisor. I wrote a bit of code for it and it gives me and error because its not right. Would anyone be kind enough to give me a hand with this. Cheers guys
SELECT employee.ename, employee.empno, boss.ename, boss.empno
FROM emp employee, emp boss
WHERE employee.super = boss.empno
OR employee.super AND boss.empno IS NULL;
Thanks in advance
-Jay
Allright guys I found the answer and I used outer join operator. The left join works but we are not taught that in our course. Thanks for that. The answer using the outer join is as follows:
SELECT employee.ename, employee.empno, boss.ename, boss.empno
FROM emp employee, emp boss
WHERE employee.super = boss.empno(+);
So it will still return rows that has null for employee.super.