not in

S

seeker

this query gives me an error in from clause

select [emp:macro] from employee where not in (select
[emp:macro] from employee2)

trying to compare two tables to see what records are
missing from the one.

seeker
 
J

John Viescas

SELECT *
FROM employee
LEFT JOIN employee2
ON employee.[emp:macro] = employee2.[emp:macro]
WHERE employee2.[emp:macro] IS NULL

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out" (coming soon)
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
D

Douglas J. Steele

John's shown you the better way to do what you're trying to do. I just
wanted to point out that why your query didn't work was because you forgot
to include a field name to use against the Not In statement:

SELECT [emp:macro]
FROM employee
WHERE [emp:macro] NOT IN (SELECT
[emp:macro] FROM employee2)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top