How to fetch data while innerjoing as one of the table misses reference data [Resolved]

Posted by Amritha444 under Sql Server on 4/13/2012 | Points: 10 | Views : 892 | Status : [Member] | Replies : 4
Hi All

I have 4 tables let it be a,b,c,d .I want to innerjoin those 4 tables to get result.Table a's Primary key will be the foregin key of b,c,d .I write a common query to innerjoin those 4 tables.but in my case there may or may not be corresponding data in b,c or d.At that time my query doesnt fetch values .Data returns only when there is a's primary key in the tables b,c and d.How to fetch data even if no datas in any of the table b,c,d.

Thanks in Advance
Amrutha.




Responses

Posted by: Pavanandey on: 4/13/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Select a.* from
a left outer join b on a.colname = b.colname

a left outer join c on a.colname = c.colname

a left outer join d on a.colname = d.colname


by using this we can fecth data even if there is no data in tables b,c,d

Thanks
Pavan Kumar
Mark Answer if this fits the need

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kk86kiran on: 4/13/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

I didnt get u clearly can u explain briefly with example code

k.m.j.kiran

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 4/13/2012 [Member] Bronze | Points: 25

Up
0
Down
Specify ur table structure...and expected Output...to be diplayed

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 4/13/2012 [Member] Bronze | Points: 25

Up
0
Down
Apply left outer join to fetch data of table a even thogh data is not present in b,c,d table.

Thanks,
Rajni Shekhar

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response