Skip to content
Advertisement

SQL query cannot use NOT LIKE to get results

I am starting out in SQL and am trying to do a query that will select all event names that are unique and do not have ‘TODAY-XXXXXXXX’ in the value for the event_name column. I have a query that works fine for getting the unique values from the table, but I cannot get the NOT LIKE to work well.

For example, I was to remove all items that have this as their name TODAY-20191021 the data at the end can change but all have the TODAY in front of the date

This is the query that is working fine

But when I try to add the where clause it fails with this error

Error running query: column “TODAY-%” does not exist LINE 3: WHERE event_name NOT LIKE “TODAY-%” ^

This is what I have so far

Advertisement

Answer

Here:

Because you use double quotes, the database considers this string as an identifier (here, a column name). Instead, you want to use single quotes, that stand for literal strings:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement