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

Records in one table not in another 1

Status
Not open for further replies.

TrekBiker

Technical User
Nov 26, 2010
330
GB
I'm wanting to extract records in the Comments Written table below that don't have matching WrittenID in the query qryWrittenWithMatchingPresentation.

Not_In_eiabky.jpg


This Select statement produces no results

Code:
SELECT [Comments Written].EntryID, [Comments Written].Judge, [Comments Written].Category, [Comments Written].Company
FROM [Comments Written]
WHERE ((([Comments Written].[WrittenID]) Not In (Select WrittenID FROM qryWrittenWithMatchingPresentation)));

I want it to show the fields for WrittenIDs 1, 2, 3, 5, 8 9 etc.

Guidance appreciated, as ever.
 
It should work, right?

Do you get the correct ID's when you just run the 'inner' Select?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Thanks Andy, your suggestion gave me confidence I was on the right track, so checked, cleared open queries etc and now have this SQL, which works!

Code:
SELECT [Comments Written].WrittenID, [Comments Written].EntryID, [Comments Written].Judge, [Comments Written].Category, [Comments Written].Company
FROM [Comments Written]
WHERE ((([Comments Written].[WrittenID]) Not In (Select WrittenID FROM qryWrittenWithMatchingPresentation)));

The vital thing I think was adding [Comments Written].WrittenID in the first Select.

Now get this, which is right.

Not_in_2_p4cbkl.jpg


Many thanks
 
TrekBiker said:
adding [Comments Written].WrittenID in the first Select

That should NOT be creating your original issue. Something else was going on, IMO

BTW - your statement could be written a lot shorter:[blue]
[tt]SELECT WrittenID, EntryID, Judge, Category, Company
FROM [Comments Written]
WHERE WrittenID Not In
(Select WrittenID FROM qryWrittenWithMatchingPresentation)
[/tt][/blue]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top