[sql] Access And/Or exclusions

I have some sample data like:

|H.RISK|NOTE|NORMAL| 

The | are actually in the data, it's a String.

I am using Access, and am trying to exclude records that contain RISK in the String.

Sample query:

SELECT * FROM someTable WHERE (UCase(someTable.Field) NOT LIKE '*RISK*') AND (UCase(someTable.Field) NOT LIKE '*Blah*') AND someTable.SomeOtherField <> 4; 

The problem is, the query is returning the above sample record, even though it does contain the string RISK.

I've tried the same query but switched to OR instead of AND but get the same results.

How can I properly structure this query to exclude records which contain certain strings?

This question is related to sql ms-access

The answer is


Seeing that it appears you are running using the SQL syntax, try with the correct wild card.

SELECT * FROM someTable WHERE (someTable.Field NOT LIKE '%RISK%') AND (someTable.Field NOT LIKE '%Blah%') AND someTable.SomeOtherField <> 4;