我有以下两个更新请求:
UPDATE TableName
SET Sector = 'NameSector'
WHERE Sector IN('') AND ThType IN ('Test2')
UPDATE TableName
SET Sector = 'NameSector1'
WHERE Sector IN('') AND ThType IN ('Test1');
如何合并?
注意:这个答案不能在ACCESS
上工作。尝试使用IIf
UPDATE TableName
SET Sector = IIF(Sector IN(' ') AND ThType IN('Test1'), 'NameSector', 'NameSector1')
WHERE (Sector IN(' ') AND ThType IN('Test1')) OR (Sector IN(' ') AND ThType IN('Test2'))
Access不支持CASE
表达式,但可以使用函数IIF()
:
UPDATE TableName
SET Sector = IIF('NameSector1' = 'Test1', 'NameSector1', 'NameSector')
WHERE Sector IN('') AND ThType IN ('Test1', 'Test2');