Pregunta

I have a problem where I am using NOT LIKE. To my knowledge, this is the correct syntax, however, the query still returns a record where [H1 Full Name] = SPEC. Any ideas why this is so?

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];
¿Fue útil?

Solución

the query still returns a record where [H1 Full Name] = SPEC

Because "SPEC" is not like "*MODEL*". I suspect you want AND instead:

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*")
)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top