Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hai friends i have one doudt if we loaded three tables called as a,b,c then we do left join for a,b and we can do right join for b,c at a time then whats the output.......
note:i try in my desktop,the output came like this,is these correct r not!!!!
attachment is given below
Hi
You can't do like this because the table b is going to join table a so there is no table b after join.if you join table c to table b you will get an error because there is no table to join.
regards,
Hari
A left join B creates a new result table with the name A. You join this
load * inline [
roll no,name
100,anil
101,bhanu
102,dhana
103,dhanush
104,prabha
];
left join
load * inline [
name,class
anil,10
dhana,7
ravi,8
prabha,6
bhanu,5
];
to get this:
roll no | name | class |
---|---|---|
101 | bhanu | 5 |
104 | prabha | 6 |
102 | dhana | 7 |
100 | anil | 10 |
103 | dhanush |
ravi does not exist in the first table, so the left join removes it from the result table. dhanush does not exist in the second table, but the left join keeps all the values from the first table so it is included in the result table. A null value is added for the class field for the dhanush record.
If you then right join this result table with:
right join
load * inline [
class,marks
5,450
6,550
10,650
2,350
1,250
];
You get this:
roll no | name | class | marks |
---|---|---|---|
1 | 250 | ||
2 | 350 | ||
101 | bhanu | 5 | 450 |
104 | prabha | 6 | 550 |
100 | anil | 10 | 650 |
class 6 does not exist in the result table from the first left join so it is removed by the final right join from the result table. Class 1 and 2 do not exist in the result table from the first left join, but do exist in the third table that's right-joined with the first result table so these class values are kept in the final result table and nulls are inserted for the roll no and name fields.