can i combine these update queries into one query

人走茶凉 提交于 2020-01-17 03:24:24

问题


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';

回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/1865147/can-i-combine-these-update-queries-into-one-query

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!