Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL query in Access update multiple fields

Tags:

sql

ms-access

Using MS Access, can I run multiple UPDATE statements in one SQL query?

Say I have a table with columns A-F. What I want to do is this:

UPDATE table SET C = NULL WHERE C = 0
UPDATE table SET D = NULL WHERE D = 0
UPDATE table SET E = NULL WHERE E = 0

I understand that with SQL Server I could use a 'GO' after each line but that doesn't seem to work with Access. Is there an alternative, or do I just have to run a load of separate queries?

like image 662
Sparrowhawk Avatar asked Oct 28 '25 10:10

Sparrowhawk


1 Answers

UPDATE table SET 
  C=IIF(C=0,NULL,C),
  D=IIF(D=0,NULL,D),
  E=IIF(E=0,NULL,E)
WHERE
  C=0 OR D=0 OR E=0
like image 144
Eugen Rieck Avatar answered Oct 30 '25 00:10

Eugen Rieck