gpt4 book ai didi

sql - 存取2013 : Why am I getting this Syntax Error?

转载 作者:行者123 更新时间:2023-12-03 08:00:56 24 4
gpt4 key购买 nike

在添加case语句之前,我没有收到错误。如果H1或H2手机字段为空或为空(作为新手,我最好的方法),我需要添加case语句以提供家庭电话号码作为备份。由于某种原因,我在查询表达式中遇到了语法错误(缺少运算符)。它记录了两个case语句的错误。据我所知,它们的书写方式正确……有人知道发生了什么吗?谢谢。

SELECT [H1 Last Name] & ", " & [H1 First Name] as [Full Name],[H1 E-Mail]
CASE
WHEN [H1 Cell Phone] IS NULL
THEN [Home Phone]
ELSE [H1 Cell Phone] END as [Phone]

FROM NameLookup
WHERE (((NameLookup.[H1 Last Name]) NOT LIKE '%SPEC%') OR ((NameLookup.[H1 Last Name]) NOT LIKE '%MODEL%')) AND ((NameLookup.[H1 Last Name]) IS NOT NULL)

UNION

SELECT [H2 Last Name] & ", " & [H2 First Name] as [Full Name],[H2 E-Mail]
CASE
WHEN [H2 Cell Phone] IS NULL
THEN [Home Phone]
ELSE [H2 Cell Phone] END as [Phone]

FROM NameLookup
WHERE (((NameLookup.[H1 Last Name]) NOT LIKE '%SPEC%') OR ((NameLookup.[H1 Last Name]) NOT LIKE '%MODEL%')) AND ((NameLookup.[H1 Last Name]) IS NOT NULL)


Order By 1;

最佳答案

您在MS Access ACE中使用它吗?大小写不可用,请使用IIF(argument, true value, false value)

SELECT [H1 Last Name] & ", " & [H1 First Name] as [Full Name],[H1 E-Mail],
IIF ( [H1 Cell Phone] IS NULL, [Home Phone], [H1 Cell Phone] ) AS Phone
FROM NameLookup

访问SQL函数: http://www.techonthenet.com/access/functions/

关于sql - 存取2013 : Why am I getting this Syntax Error?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22244110/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com