How to Use Multiple Joins in DB2

Big Analytics
Big Analytics

The below is the best example to go ahead on multiple joins:

SELECT m.f1, o.f1, s.f1
FROM Material m
LEFT OUTER JOIN Catalog c
ON m.MaterialName = c.MaterialName
AND m.EffectiveDate = c.EffectiveDate
AND c.MaterialType = ‘X1’ AND (c.MaterialName Like ‘xyz%’ OR
c.MaterialName Like ‘%abc’)
LEFT OUTER JOIN OrderHeader o
ON o.OrderList = m.OrderList
AND o.OrderDate BETWEEN ’01-01-2004′ AND ’12-31-2004′
LEFT OUTER JOIN Ship s
ON o.OrderList = s.OrderList
AND s.ShipVendorID in (‘UPS’,’YF’)

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.