silverkid
silverkid

Reputation: 9563

can i combine these update queries into one query

In an MS-Access database with Table called NewTable3

can i combine these 3 sql queries into one query

UPDATE NewTable3 SET SAO = '0' WHERE SAO LIKE '-';
UPDATE NewTable3 SET SAO = '0' WHERE SAO LIKE 'NULL';
UPDATE NewTable3 SET SAO = '0' WHERE SAO LIKE 'NA';

Upvotes: 0

Views: 361

Answers (2)

Mitch Wheat
Mitch Wheat

Reputation: 300529

UPDATE NewTable3 
SET SAO = '0' 
WHERE (WAP LIKE '-') OR (WAP IS NULL) OR (WAP LIKE 'NA');

Upvotes: 4

Adam Matan
Adam Matan

Reputation: 136141

What about using OR?

UPDATE NewTable3 
SET SAO = '0' 
WHERE (WAP LIKE '-') OR (WAP IS NULL) OR (WAP LIKE 'NA');

You can learn more about using AND and OR in SQL queries here.

The original question included the condition WAP LIKE 'NULL'. The correct notation is WAP IS NULL" and not WAP LIKE 'NULL'; Null isn't the text NULL but a special, none-textual value.

Upvotes: 4

Related Questions