我正在尝试根据type_match
表中两列2018_status
和2019_status
的内容填充一个标记为status_report
的列。
所有三列均为短文本。我不断收到“语法错误”。
UPDATE status_report AS per
SET per.type_match =
Switch(
per.2018_status = 'No application found', 'No application for 2018',
per.2019_status = 'No application found', 'NA',
per.2018_status = per.2019_status, 'Yes',
True, 'No'
)
该文档似乎非常简单,并且认为这是MS Access问题,因此他们往往非常挑剔。
答案 0 :(得分:1)
Switch没什么问题,您只需要将方括号括起来的列名就可以了:
UPDATE status_report AS per
SET per.type_match =
Switch(
per.[2018_status] = 'No application found', 'No application for 2018',
per.[2019_status] = 'No application found', 'NA',
per.[2018_status] = per.[2019_status], 'Yes',
True, 'No'
)
答案 1 :(得分:0)
您可以使用1=1
作为默认值:
UPDATE status_report AS per
SET per.type_match = Switch(per.2018_status = "No application found", "No application for 2018,
per.2019_status = "No application found", "NA",
per.2018_status = per.2019_status, "Yes",
1=1, "No"
);
MS Access传统上也对字符串使用双引号,因此我也对其进行了更改。