[sql] Access And/Or exclusions

I have some sample data like:


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; 

Questions with sql tag:

Passing multiple values for same variable in stored procedure SQL permissions for roles Generic XSLT Search and Replace template Access And/Or exclusions Pyspark: Filter dataframe based on multiple conditions Subtracting 1 day from a timestamp date PYODBC--Data source name not found and no default driver specified select rows in sql with latest date for each ID repeated multiple times ALTER TABLE DROP COLUMN failed because one or more objects access this column Create Local SQL Server database Export result set on Dbeaver to CSV How to create temp table using Create statement in SQL Server? SQL Query Where Date = Today Minus 7 Days How do I pass a list as a parameter in a stored procedure? #1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’ MySQL Error: : 'Access denied for user 'root'@'localhost' SQL Server IF EXISTS THEN 1 ELSE 2 How to add a boolean datatype column to an existing table in sql? Presto SQL - Converting a date string to date format What is the meaning of <> in mysql query? Change Date Format(DD/MM/YYYY) in SQL SELECT Statement Convert timestamp to date in Oracle SQL #1292 - Incorrect date value: '0000-00-00' Postgresql tables exists, but getting "relation does not exist" when querying SQL query to check if a name begins and ends with a vowel Find the number of employees in each department - SQL Oracle Error in MySQL when setting default value for DATE or DATETIME Drop view if exists Could not find server 'server name' in sys.servers. SQL Server 2014 How to create a Date in SQL Server given the Day, Month and Year as Integers TypeError: tuple indices must be integers, not str Select Rows with id having even number SELECT list is not in GROUP BY clause and contains nonaggregated column IN vs ANY operator in PostgreSQL How to insert date values into table Error related to only_full_group_by when executing a query in MySql How to select the first row of each group? Connecting to Microsoft SQL server using Python eloquent laravel: How to get a row count from a ->get() How to execute raw queries with Laravel 5.1? In Oracle SQL: How do you insert the current date + time into a table? Extract number from string with Oracle function Rebuild all indexes in a Database SQL: Two select statements in one query DB2 SQL error sqlcode=-104 sqlstate=42601 What difference between the DATE, TIME, DATETIME, and TIMESTAMP Types How to run .sql file in Oracle SQL developer tool to import database? Concatenate columns in Apache Spark DataFrame How Stuff and 'For Xml Path' work in SQL Server? Fatal error: Call to a member function query() on null

Questions with ms-access tag:

How to get parameter value for date/time column from empty MaskedTextBox Access And/Or exclusions Get length of array? How to pass an array to a function in VBA? How to insert values into the database table using VBA in MS access Access 2013 - Cannot open a database created with a previous version of your application Does VBA contain a comment block syntax? java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver Exception occurring. Why? Manipulating an Access database from Java without ODBC How to find longest string in the table column data Access Form - Syntax error (missing operator) in query expression Multiple INNER JOIN SQL ACCESS VBA shorthand for x=x+1? How to connect PHP with Microsoft Access database "Operation must use an updateable query" error in MS Access JDBC ODBC Driver Connection "You tried to execute a query that does not include the specified aggregate function" where to place CASE WHEN column IS NULL in this query how to refresh my datagridview after I add new data MS Access VBA: Sending an email through Outlook Convert String to Date in MS Access Query Row numbers in query result using Microsoft Access Is it possible to pass parameters programmatically in a Microsoft Access update query? Using Excel VBA to export data to MS Access table What is the equivalent of Select Case in Access SQL? How to get start and end of previous month in VB Does MS Access support "CASE WHEN" clause if connect with ODBC? How to SUM two fields within an SQL query Corrupted Access .accdb file: "Unrecognized Database Format" How do I count unique items in field in Access query? VBA procedure to import csv file into access How to open a folder in Windows Explorer from VBA? How to use a SQL SELECT statement with Access VBA How to connect to a MS Access file (mdb) using C#? How to use "like" and "not like" in SQL MSAccess for the same field? MS Access - execute a saved query by name in VBA How to open Form in Add record How to select top 10 in Access query? How to add default signature in Outlook Access VBA | How to replace parts of a string with another string How to query a MS-Access Table from MS-Excel (2010) using VBA How to I say Is Not Null in VBA Import an Excel worksheet into Access using VBA How do I test if a recordSet is empty? isNull? SQL to Query text in access with an apostrophe in it How to execute VBA Access module? Access: Move to next record until EOF Access Database opens as read only Code to loop through all records in MS Access How can I convert an MDB (Access) file to MySQL (or plain SQL file)?