2014-03-13 71 views
0

我遇到問題,我正在使用NOT LIKE。據我所知,這是正確的語法,但是,查詢仍然返回一個記錄,其中[H1 Full Name] = SPEC。任何想法爲何如此?MS Access 2013:「不喜歡」不會返回想要的結果

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]; 

回答

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*") 
)