Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, Trying to understand the various joins. Can someone look at this? I am puzzled why I don't get to see the DOB for emp no 203.
Thanks
Ram
Left joins based on the previously loaded records.
You added the employee(203) after you applied the left join on the DOB table.
A left join means that all values from the preceding table are included, and only those that exist in that table will be added from the next load statement. So in your script:
emp_details:
load * inline
[
empno,name, salary
200,Ramkumar, 50000
201, Ramkishore,8000000
202, Akshay, 200000
];
inner join
load * inline
[
empno, city
200, Singapore
201, Abhu Dhabi
202, Perth
];
left join
load * inline
[
empno, dob
200, 22-apr-1976
201, 13-feb-2003
202, 11-11-2008
203, 18-Dec-1982
];
outer join
load * inline
[
empno, name
203, Ramji
];
Since there was no empno 203 in your first few tables, it won't add it. It only takes the piece from the outer join at the end.
Try switching the dob load to an outer join, and it should work.
Actually, I looked again, and switching it to an outer join wouldn't work by itself. Try the script like this:
emp_details:
load * inline
[
empno,name, salary
200,Ramkumar, 50000
201, Ramkishore,8000000
202, Akshay, 200000
];
inner join
load * inline
[
empno, city
200, Singapore
201, Abhu Dhabi
202, Perth
];
Concatenate
load * inline
[
empno, name
203, Ramji
];
outer join
load * inline
[
empno, dob
200, 22-apr-1976
201, 13-feb-2003
202, 11-11-2008
203, 18-Dec-1982
];
We switch adding the name for 203 to right after the other names, so we can concatenate it easily, instead of doing a join. We also switch the dob load to an outer join.
For adding the name for 203, you can concatenate or use an outer join, either way will work.