简体   繁体   中英

Problem in append query in MS ACCESS sql

I am using MS Access. I have written this query...

INSERT INTO survey1 ( [Coach No] )
SELECT pvc1.[Coach No]
FROM pvc1 LEFT JOIN survey1 ON pvc1.[Coach No]=survey1.[Coach No]
WHERE (((survey1.[Coach No]) Is Null));

BUT it is not appending data in my table survey1...

Break the query up. Does just the select return any results?

SELECT pvc1.[Coach No]
FROM pvc1 LEFT JOIN survey1 ON pvc1.[Coach No]=survey1.[Coach No]
WHERE (((survey1.[Coach No]) Is Null))

Your query doesn't make sense. You are joining on NULL , then you try to insert that NULL into a table as a PK where it originally came from. You are joining with survey1 on Coach No and are trying to insert the Coach No back into survey1 What are you trying to do here?

Update now that OP elaborated on what he wants to do:

INSERT INTO survey1 ( [Coach No] )
SELECT pvc1.[Coach No]
FROM pvc1 
WHERE pvc1.[Coach No] NOT IN (SELECT [Coach No] FROM survey1 WHERE NOT [Coach No] IS NULL)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM