Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Table Joins Syntax Problems

Status
Not open for further replies.

nguenthe

MIS
Jul 2, 2004
16
US
Here is the code i am trying to wokr through.
All seems to work fine until I incorporated the iCi table.
I cannot figure out how to set up the joins in the right order.
Can anyone please help?

Code:
SELECT i.itemnum, 
       i.description1, 
       i.udindx3                                  AS 'Customer', 
       c.slsp, 
       w.whse, 
       c.name, 
       w.onhandqty, 
       w.committedqty, 
       w.lastpurchdate, 
       w.lastsaledate, 
       w.avgcost, 
       w.wipqty, 
       ( w.onhandqty + w.wipqty )                 AS 'QOH+WIP', 
       ( ( w.onhandqty + w.wipqty ) * w.avgcost ) AS 'EXT_QOH', 
       w.avgleadtime 
FROM   domdata.pub.icwhseitem AS w 
       INNER JOIN (domdata.pub.icitem AS i 
                   INNER JOIN domdata.pub.arcustomer AS c 
                     ON ( i.udindx3 = c.custnum ) 
                        AND ( i.conum = c.conum ) 
                   LEFT JOIN domdata.pub.icinterchange AS ici 
                     ON ( i.conum = ici.conum ) 
                        AND ( i.itemnum = ici.itemnum ) 
                        AND ( i.udindx3 = ici.custnum ) 
                        AND ici.TYPE = '2') 
         ON ( w.itemnum = i.itemnum ) 
            AND ( w.conum = i.conum ) 
WHERE  ( ( ( w.whse ) = 'WH1' ) 
         AND ( ( w.onhandqty + w.wipqty ) > 0 ) )
 
IS ici.TYPE text or numeric?
Code:
ici.TYPE = '2'
If numeric, remove the single quotes.

Or, more likely, you simply need to move that criteria from the LEFT JOIN to the WHERE clause:
Code:
LEFT JOIN domdata.pub.icinterchange AS ici 
                     ON ( i.conum = ici.conum ) 
                        AND ( i.itemnum = ici.itemnum ) 
                        AND ( i.udindx3 = ici.custnum )) 
                         
         ON ( w.itemnum = i.itemnum ) 
            AND ( w.conum = i.conum ) 
WHERE  ( ( ( w.whse ) = 'WH1' ) 
         AND ( ( w.onhandqty + w.wipqty ) > 0 ) AND [red][b](ici.TYPE = '2')[/b][/red] )

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top