[英]MS Access 2013: Nested IIF Syntax Error
I can't figure out why I am receiving a syntax error in access sql for the following nested IIF - it works if I remove the top line and closing parenthesis... Thanks 我无法弄清楚为什么我在访问SQL中收到以下嵌套IIF的语法错误-如果我删除了顶行并关闭了括号,它会起作用...谢谢
IIF(
[Home Phone] IS NULL
AND [H1 Cell Phone] IS NULL
, [Home Phone]
, IIF(
[H1 Cell Phone] IS NOT NULL
, [H1 Cell Phone] & ' (m)'
, [Home Phone] & ' (h)'
) AS Phone
)
Try moving the "AS Phone" part outside of the closing parenthesis. 尝试将“ AS Phone”部分移到右括号之外。 It looks like your IIf can be split up as: 看来您的IIf可以拆分为:
IIF(
[Home Phone] IS NULL AND [H1 Cell Phone] IS NULL, -- Conditional
[Home Phone], -- Conditional true If they're both null, why are you displaying null here?
-- Conditional false
IIF(
[H1 Cell Phone] IS NOT NULL, -- Conditional
[H1 Cell Phone]&' (m)', - True
[Home Phone]&' (h)' - False
) AS Phone --I think the AS Phone part needs to be moved outside the IIF or removed entirely.
)
See http://office.microsoft.com/en-us/access-help/iif-function-HA001228853.aspx for examples on how to use IIF as well. 有关如何也使用IIF的示例,请参见http://office.microsoft.com/zh-cn/access-help/iif-function-HA001228853.aspx 。
IIF([Home Phone] IS NULL AND [H1 Cell Phone] IS NULL,[Home Phone],
IIF([H1 Cell Phone] IS NOT NULL, [H1 Cell Phone]&' (m)', [Home Phone]&' (h)')) AS Phone
Parenthesis is misplaced. 括号放错了位置。 You must trouble shoot this in pieces. 您必须为此付出很多努力。 Find parts taht work, and build up. 找到可以工作的零件,然后进行组装。
Remember IIF - is constructed with the format: IIF(SOME_TEST,TRUE_CONDITION,ELSE_FALSE_CONDITION)
记住IIF(SOME_TEST,TRUE_CONDITION,ELSE_FALSE_CONDITION)
以以下格式构造: IIF(SOME_TEST,TRUE_CONDITION,ELSE_FALSE_CONDITION)
At first glance, you are missing a closing paranthesis.. 乍一看,您错过了一个圆括号。
IIF([Home Phone] IS NULL AND [H1 Cell Phone] IS NULL,[Home Phone],
IIF([H1 Cell Phone] IS NOT NULL, [H1 Cell Phone]&' (m)', [Home Phone]&' (h)') AS Phone
))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.