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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql query help on linking tables

Status
Not open for further replies.

ss7415

Programmer
Dec 7, 2006
84
US
i want to link my tables on two different criteria's.

im getting an error with this, but you can see what im trying to do

select a,qad.VENDOR,qad.PO_NBR,qad.PO_ITEM_NBR,qad.lot_nbr,qad.DATE_RCV,qad.PART,qad.ord_PART,qad.PROJECT_ONLY,qad.WO_NBR,qad.VDESC,qad.QTY_ORIG,qad.QTY_OPEN,qad.RCVR,
qty_onhand,qty_last_rcv

from qad left outer join idf_table idf on
(if qad.part is not null and idf.lot_nbr is not null then (qad.part = idf.part) and (qad.lot_nbr = idf.lot_nbr))
(if qad.ord_part is not null and qad.wo_nbr is not null then (qad.ord_part = idf.part) and (qad.a = qad.lot_nbr))
 
Have you tried this ?
...
FROM qad LEFT JOIN idf_table idf
ON (qad.part = idf.part AND qad.lot_nbr = idf.lot_nbr)
OR (qad.ord_part = idf.part AND qad.a = [!]qad[/!].lot_nbr)

The red part is really what you want ?


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top