I wanted to know the difference between these two SQL queries..
Note: Foreign Key = dept_no
Query1:
SELECT emp_no, emp_name, emp.dept_no, dept_name, loc
from emp,dept
WHERE emp.dept (+)= dept.dept_no;
Query2:
SELECT emp_no, emp_name, emp.dept_no, dept_name, loc
from emp,dept
WHERE emp.dept = dept.dept_no(+);
Basically my question is about the position of the Outer Join.
Thanks!
The position of the
outer join(left or right) determines from which of the tables to return all rows even if no matching rows from the related table exist. Therefore…The first (
left outer join) will return all employee information (all rows fromemp) even if not associated with a department.The second (
right outer join) will return all department names & department numbers (all rows fromdept), even if no employees belong to that department.