Tuesday, 27 November 2012

Outer Joined better understanding


Hi Guys,

Below is something which sounds very simple.But understanding it will give you a better understanding of queries

Emp.emp_id = dept.emp_id(+)
dept.abc_id =state.abc_id(+)

the main driving force here is emp here .notice that it has outer join with dept .So in simple terms it means it will return all the values for emp even if
there are no matching values in dept.Notice there are no matching values in dept corresponding to emp_id so all are null then you try to join state based on
abc_id id to dept .Now since abc_id is null there wont be any location picked up .
So here the data is control based on emp. to get data you need to insert data into dept table with corresponding emp_id

So point to remember are when you are joining is outer join allows you to join nulls as if one side is null it cannot find anything matching on other sides
substitutes null. second once you outer join on one table and then you join the non driving table to other table .The driving table controls your data.In
this case driving table is EMP

No comments:

Post a Comment