Skip to content
Advertisement

How do I add multiple “NOT LIKE ‘%?%’ in the WHERE clause of sqlite3?

I have a sqlite3 query like:

This would select all of the words where ‘a’ does not occur in the word. This I can get to work perfectly. The problem is if I want to further restrict the results to not include ‘b’ anywhere in the word. I am picturing something like this.

which this obviously does not work, but this is the idea. Just adding an AND clause is what I’m trying to avoid:

If this is the only option then I will have to work with that, but I was hoping for something else.

Advertisement

Answer

If you use Sqlite’s REGEXP support ( see the answer at Problem with regexp python and sqlite for how to do that ) , then you can do it easily in one clause:

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