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

SQL Query Problem with Not Exists

Status
Not open for further replies.

dom24

Programmer
Aug 5, 2004
218
GB
Hi,

Can someone please tell me how to write the query for the following problem as I can't seem to get it right.

I have 2 tables, one named CourseComplete and one named Validation. Both contain the fields CourseKey and Staffno. I want to select all the records from coursecomplete where the coursekey and staffno combination are not in the Validation table.

I currently have:

SELECT * from coursecomplete
WHERE NOT EXISTS (select staffno, coursekey from validation)

but this doesn't work.

Thanks.
 
I hate how you get the answer soon as you post!

It should've been:

SELECT * from coursecomplete
WHERE NOT EXISTS (select * from validation where validation.staffno = coursecomplete.staffno
and validation.coursekey = coursecomplete.coursekey)

thanks anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top