MS Access 2013:"不喜欢"没有返回所需的结果

时间:2014-03-13 13:32:49

标签: sql ms-access ms-access-2013

我在使用NOT LIKE时遇到问题。据我所知,这是正确的语法,但是,查询仍返回[H1 Full Name] = SPEC的记录。任何想法为什么会这样?

SELECT [Unit Owner Listing].[Unit#], 
    [Unit Owner Listing].[Combined Name], 
    [Unit Owner Listing].Address, 
    [Unit Owner Listing].[Home Phone], 
    [Unit Owner Listing].[H1 Cell Phone], 
    [Unit Owner Listing].[H1 E-Mail], 
    [Unit Owner Listing].[H2 Cell Phone], 
    [Unit Owner Listing].[H2 E-Mail], 
    [Unit Owner Listing].[H1 Last Name] & ', ' & [Unit Owner Listing].[H1 First Name] AS [H1 Full Name], 
    IIF([Unit Owner Listing].[H2 Last Name] IS NOT NULL,
        [Unit Owner Listing].[H2 Last Name] & ', ' & [Unit Owner Listing].[H2 First Name],
        NULL) AS [H2 Full Name]
FROM [Unit Owner Listing]
WHERE (
    (([Unit Owner Listing].[H1 Last Name])<>"")
    OR
    (([Unit Owner Listing].[H1 Last Name]) Not Like "*SPEC*")
    OR
    (([Unit Owner Listing].[H1 Last Name]) Not Like "*MODEL*")
    )
ORDER BY [Unit Owner Listing].[H1 Last Name];

1 个答案:

答案 0 :(得分:4)

  

查询仍会返回[H1 Full Name] = SPEC

的记录

因为"SPEC""*MODEL*"不同。我怀疑你想要AND而不是:

WHERE 
(
(([Unit Owner Listing].[H1 Last Name])<>"")
AND
(([Unit Owner Listing].[H1 Last Name]) Not Like "*SPEC*")
AND
(([Unit Owner Listing].[H1 Last Name]) Not Like "*MODEL*")
)