Reputation: 135
I need to join 3 tables using left outer join .Let me give you an example using 3 tables .In the below image we can see Table:[A.TableMaster] the drugDescription Column must be equal to Table:[C.Table2]-DrugDescription column [A.drugDescription=C.DrugDescription] and [C.drug=B.drug] according to the drug the Price is to be assigned from Table:[B.Table1] . and also with the b.date
in simple english the user selects a date for the particular drug and price assigned for the drug
Image of the Tables:TableMaster,Table1,Table2
e.g
case WHEN Drug='OCTAGAM' THEN [b.price],
but i m not able to relate with the outer join and the three table seems confusing please Help..
Upvotes: 3
Views: 8279
Reputation: 4187
I guess the query is simple as that:
SELECT a.*, c.Price
FROM TableMaster AS a
LEFT OUTER JOIN Table2 AS b ON b.DrugDescription = a.DrugDescription
LEFT OUTER JOIN Table1 AS c ON c.Drug = b.Drug
AND c.Date = a.Date
Upvotes: 2