gpt4 book ai didi

sql - Access 2013 SQL : "IS NOT LIKE" issue

转载 作者:行者123 更新时间:2023-12-02 21:31:13 24 4
gpt4 key购买 nike

我无法弄清楚为什么我的 WHERE 子句似乎仍然返回值为“SPEC”的列值...我在这里做错了什么? [H1 姓氏] 是唯一包含此名称/值的列。

SELECT [H1 LAST Name] & ", " & [H1 FIRST Name] AS [FULL Name],
[H1 E-Mail] AS [E-Mail],
IIF([H1 Cell Phone] IS NULL, [Home Phone], [H1 Cell Phone]) 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 ALL

SELECT [H2 LAST Name] & ", " & [H2 FIRST Name] AS [FULL Name],
[H2 E-Mail] AS [E-Mail],
IIF([H2 Cell Phone] IS NULL, [Home Phone], [H2 Cell Phone]) AS Phone
FROM NameLookup
WHERE ((NameLookup.[H1 LAST Name] NOT LIKE '%SPEC%') OR (NameLookup.[H1 LAST Name] NOT LIKE '%MODEL%'))
AND (NameLookup.[H2 LAST Name] IS NOT NULL)

ORDER BY [FULL NAME]

最佳答案

您的查询接受记录,其中

(NameLookup.[H1 LAST Name] NOT LIKE '%SPEC%') OR (NameLookup.[H1 LAST Name] NOT LIKE '%MODEL%')

因此,如果姓氏不包含“MODEL”但包含“SPEC”,它将进入您的结果。

关于sql - Access 2013 SQL : "IS NOT LIKE" issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22257034/

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