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!

need help with multi column lookup

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I need to verify 3 things
1. the ID number is valid.
2. the AssociateID is valid
3 the AssociateID gose the the correct ID
I have two tables
table 1. just has 2 columns with
ID AssociateID
1 11
1 12
1 13
2 14
3 15
3 16
Table 2. users with ID and the AssociateID they submit for time.

then the users are submitting time to the ID
User ID AssociateID
A 1 11
A 2 14
B 3 15
C 1 16 ' < this is a bad record in other words 16 does not go with ID 1, it goes with ID 3.
Is there a way to make a one line SQL statement to show any of the above 3 criteria are not met and then show which user faulted?
BTW we are working on a new form which won't allow users to pick ID and AssociateID that do not match, we are just not there yet.
I have this but it only checks ID's
Code:
SELECT ExportExcelSheet1.SPMID, ExportExcelSheet1.CostTracker
FROM ExportExcelSheet1 LEFT JOIN SPMID ON ExportExcelSheet1.[SPMID] = SPMID.[smpid]
WHERE (((SPMID.smpid) Is Null));
[\code]

TIA

DougP
 
SELECT T2.*
FROM [Table 2] T2 LEFT JOIN [table 1 ] T1 ON T2.ID=T1.ID AND T2.AssociateID=T21AssociateID
WHERE T1.ID Is Null

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top