【问题标题】:MS Access 2013: "NOT LIKE" not return desired resultsMS Access 2013:“不喜欢”不返回所需的结果
【发布时间】:2014-03-13 13:32:49
【问题描述】:

我在使用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];

【问题讨论】:

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


    【解决方案1】:

    查询仍然返回[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*")
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-06
      • 1970-01-01
      • 2019-02-04
      • 1970-01-01
      • 2020-04-24
      • 1970-01-01
      • 2013-12-04
      • 2023-03-20
      相关资源
      最近更新 更多