IIF() - 语法错误无效

时间:2018-03-30 14:50:33

标签: sql ms-access iif

尝试运行此IIF语句时,我一直收到此错误。

enter image description here

以下是我所拥有的:

IIF([Explanation] Like "*No Alternative*" Or Like "*1*" Or Like "*least costly room*" Or Like "*best possible rate*" Or Like "*best rate available*" Or Like "*best available rate*" Or Like "*least expensive*" Or Like "*cheapest hotel room*" Or Like "*lowest price*" Or Like "*cheapest rate*", “No Alternative”, IIF([Explanation] Like "*Required location*" Or Like "*2*", “Required Location”, IIF([Explanation] Like "*Least total cost*" Or Like "*3*" Or Like "*most economical*", “Least Total Cost”, “No Alternative”)))

2 个答案:

答案 0 :(得分:3)

而不是

[black, blue, yellow, red, pink, green, cyan]
[black, blue, yellow, red, pink, green, cyan, null, I]

你需要

[Explanation] Like "*No Alternative*" Or Like "*1*"

答案 1 :(得分:1)

你应该检查每个OR中的[说明],例如:

IIF( ([Explanation] Like "*No Alternative*" 
Or [Explanation] Like "*1*" 
Or [Explanation] Like "*least costly room*" 
Or [Explanation] Like "*best possible rate*" 
Or [Explanation] Like "*best rate available*" 
Or [Explanation] Like "*best available rate*" 
Or [Explanation] Like "*least expensive*" 
Or [Explanation] Like "*cheapest hotel room*" 
Or [Explanation] Like "*lowest price*" 
Or [Explanation] Like "*cheapest rate*"), "No Alternative", 

  IIF( ([Explanation] Like "*Required location*" 
    Or [Explanation] Like "*2*"), "Required Location", 

      IIF( ([Explanation] Like "*Least total cost*" 
        Or [Explanation] Like "*3*" 
        Or [Explanation] Like "*most economical*"), "Least Total Cost",
             "No Alternative")))