Full Version: How Can I Get This Insert Into Working?
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
token_remedie
trying to get matching data from my query to insert into an existing table, nothing happens it just sits there, any ideas?


INSERT INTO Transactions ( [Asset Number], [Location Name] )
SELECT Books.[Asset Number], Books.[Location Name]
FROM Books INNER JOIN Tabletest ON Books.[Asset Number] = Tabletest.[Asset Number]
WHERE (((Books.[Asset Number]) Is Not Null));
GroverParkGeorge
Are you sure the query finds records to insert? When you have this query in the query designer, select "Datasheet View" to see the records that will be inserted. Are there any?
vtd
QUOTE (token_remedie @ Sep 22 2011, 11:53 AM) *
INSERT INTO Transactions ( [Asset Number], [Location Name] )
SELECT Books.[Asset Number], Books.[Location Name]
FROM Books INNER JOIN Tabletest ON Books.[Asset Number] = Tabletest.[Asset Number]
WHERE (((Books.[Asset Number]) Is Not Null));

The SELECT clause (which can be a SELECT SQL on its own) of the INSERT SQL will never return any row because of the contradictory conditions on the INNER JOIN and the WHERE clause. Thus, your INSERT SQL has nothing to append, ever.

Suggest you first try the SELECT Query/SQL only until the SELECT Query/SQL returns the rows as required and then use the SELECT SQL as part of your INSERT SQL.

Hint: Check your Access Help on LEFT JOIN / RIGHT JOIN operations.

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.