Sunshine
Sunshine

Reputation: 23

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...

Upvotes: 1

Views: 668

Answers (2)

Jacob
Jacob

Reputation: 43309

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)

Upvotes: 1

Al W
Al W

Reputation: 7713

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))

Upvotes: 2

Related Questions