Skip to main content
Announcements
Jan 15, Trends 2025! Get expert guidance to thrive post-AI with After AI: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

doudt on joins!!!!!!!!!!

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

2 Replies
hari8088
Creator
Creator

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

Gysbert_Wassenaar

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
101bhanu5
104prabha6
102dhana7
100anil10
103dhanush

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
1250
2350
101bhanu5450
104prabha6550
100anil10650

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.


talk is cheap, supply exceeds demand