Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple UPDATEs in one Access SQL query

I'm trying to make a query like so:

UPDATE table1 SET col1 = 'foo', col2 = 'bar';
UPDATE table2 SET hi = 'bye', bye = 'hi';

But when I go to save, Access errors with:

Characters found after end of SQL statement

After some searching, it would appear this is because Access can only do one query at a time.

How can I do this?

like image 942
Danny Beckett Avatar asked Oct 07 '22 13:10

Danny Beckett


1 Answers

Where are you working? You can run multiple queries in VBA or via macros. Some examples:

CurrentDB.Execute "UPDATE table1 SET col1 = 'foo', col2 = 'bar';", dbFailOnError
CurrentDB.Execute "UPDATE table2 SET hi = 'bye', bye = 'hi';", dbFailOnError

Saved query:

CurrentDb.Execute "Query5", dbFailOnError
like image 97
Fionnuala Avatar answered Oct 13 '22 11:10

Fionnuala