Full Version: Not In(SELECT SSN FROM TABLE)
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
thefalcon
I'm trying to use a SubQuerry as my criteria for appending info from one table to another.

Its not working

I've use the same subquerry in other append querries and it works fine.

Criteria: Not In(SELECT SSN FROM TABLE)

Note: The table i'm trying to append to presently has no data.

Any suggestions
Doug Steele
"its not working" doesn't really give us much to go on...

Are you getting an error? If so, what's the error?

What's the complete SQL of your query?
thefalcon
INSERT INTO tblSoldiers ( Name, Address, City, State, Zip, SidpersHome, SidpersWork, SidpersNOK, Grade )
SELECT SIDPERS.NAME, SIDPERS.STREET, SIDPERS.CITY, SIDPERS.STATE, SIDPERS.ZIP, PERS_SVCMBR_TBL.HOME_PH, PERS_SVCMBR_TBL.WORK_PH, PERS_SVCMBR_TBL.NOK_PH, SIDPERS.GRADE
FROM SIDPERS LEFT JOIN PERS_SVCMBR_TBL ON SIDPERS.SSN = PERS_SVCMBR_TBL.SSN
WHERE (((SIDPERS.SSN) Not In (SELECT Ssn FROM tblSoldiers)));

My bad

It does work. It just appends "0" records.
Doug Steele
I hate to ask the obvious, but are you sure

SELECT SIDPERS.NAME, SIDPERS.STREET, SIDPERS.CITY, SIDPERS.STATE, SIDPERS.ZIP, PERS_SVCMBR_TBL.HOME_PH, PERS_SVCMBR_TBL.WORK_PH, PERS_SVCMBR_TBL.NOK_PH, SIDPERS.GRADE
FROM SIDPERS LEFT JOIN PERS_SVCMBR_TBL ON SIDPERS.SSN = PERS_SVCMBR_TBL.SSN

returns data?

What about

SELECT SIDPERS.NAME, SIDPERS.STREET, SIDPERS.CITY, SIDPERS.STATE, SIDPERS.ZIP, PERS_SVCMBR_TBL.HOME_PH, PERS_SVCMBR_TBL.WORK_PH, PERS_SVCMBR_TBL.NOK_PH, SIDPERS.GRADE
FROM SIDPERS LEFT JOIN PERS_SVCMBR_TBL ON SIDPERS.SSN = PERS_SVCMBR_TBL.SSN
WHERE (((SIDPERS.SSN) Not In (SELECT Ssn FROM tblSoldiers)));
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.