Barry
Barry

Reputation: 1

Access 2007: Insert query

I'm working on two tables in Access 2007 and the query below results in zero records. I'd like to copy the client ID into the transactions table.

INSERT INTO Transactions (NAME_ID) SELECT ID FROM Clients WHERE not exists (select * from Transactions where Transactions.Name=Clients.Name);

Thank you in advance, Barry

Upvotes: 0

Views: 729

Answers (1)

SeanC
SeanC

Reputation: 15923

You need an UPDATE query, not a INSERT

UPDATE clients INNER JOIN transactions ON clients.Name = transactions.Name  
SET transactions.Name_ID = [clients].[ID];

The part after UPDATE defines the join between tables the part after SET defines what items you want to update

Upvotes: 1

Related Questions