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

need to link tables with different criteria

Status
Not open for further replies.

ss7415

Programmer
Dec 7, 2006
84
US
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 qad.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))
 
Query like this:

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 inner join idf_table idf on
qad.part = idf.part and qad.lot_nbr = idf.lot_nbr and
qad.ord_part = idf.part and qad.a = qad.lot_nbr
 
I'm sorry I need to add this, assuming you have all the column names correct you would also need to add

and qad.wo_nbr is not null

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top