I have written the query like:
1 select resort.resortid,resort.resortname,nvl(manager.name,'NA')MANAGERNAME, 2 nvl(manager.phone,'NA')PHONENO 3 from resort join manager on resort.managerid=manager.managerid 4 order by resort.resortid;
Problem is, I’m not getting the output containing null values
Advertisement
Answer
A regular (inner) join
will only return rows that match the join condition. You’re looking for a left join
:
SELECT resort.resortid, resort.resortname, NVL(manager.name,'NA' ) managername, NVL(manager.phone,'NA') phoneno FROM resort LEFT JOIN manager ON resort.managerid = manager.managerid ORDER BY resort.resortid;