我需要在MS Access中运行以下SQL查询。有人能够解释如何将其转换为正确的语言吗?
UPDATE osmm_topo.boundaryline SET style_description =
CASE
WHEN featurecode = 10136 THEN 'Parish Boundary'
WHEN featurecode = 10131 THEN 'District Boundary'
WHEN featurecode = 10128 THEN 'Electoral Boundary'
WHEN featurecode = 10127 THEN 'County Boundary'
WHEN featurecode = 10135 THEN 'Parliamentary Boundary'
ELSE 'Unclassified'
END,
style_code =
CASE
WHEN featurecode = 10136 THEN 1
WHEN featurecode = 10131 THEN 2
WHEN featurecode = 10128 THEN 3
WHEN featurecode = 10127 THEN 4
WHEN featurecode = 10135 THEN 5
ELSE 99
END;
答案 0 :(得分:3)
我认为tahe Switch
函数在您的情况下将是您的朋友:
UPDATE osmm_topo.boundaryline SET style_description =
Switch(
featurecode = 10136, 'Parish Boundary',
featurecode = 10131, 'District Boundary',
featurecode = 10128, 'Electoral Boundary',
featurecode = 10127, 'County Boundary',
featurecode = 10135, 'Parliamentary Boundary',
True, 'Unclassified'),
style_code =
Switch(
featurecode = 10136, 1,
featurecode = 10131, 2,
featurecode = 10128, 3,
featurecode = 10127, 4,
featurecode = 10135, 5,
True, 99);
答案 1 :(得分:1)
您可以尝试使用IIF
IIf(expr,truepart,falsepart)
代替CASE WHEN
中的ms-access
UPDATE osmm_topo.boundaryline SET style_description = IIF(featurecode = 10136, 'Parish Boundary',IIF(featurecode = 10131,'District Boundary',IIF(featurecode = 10128,'Electoral Boundary',IIF(featurecode = 10127,'County Boundary',IIF(featurecode = 10135,'Parliamentary Boundary','Unclassified'))))) ,
style_code = IIF(featurecode = 10136, 1 IIF(featurecode = 10131,2,IIF(featurecode = 10128,3,IIF(featurecode = 10127,4,IIF(featurecode = 10135,5,99)))))