Skip to content
Advertisement

postgresql two NOT LIKE clauses returning wrong results

I have a table with 88 codes. I am writing a simple select statement that does not select the codes that start with 10 or 18

one would assume this would work but it returns ALL the results

If i just run each one of those like clauses by themselves they return the correct results. what am I doing wrong here?

Advertisement

Answer

When combining NOT LIKE then AND should be used instead of OR

It’s a logical thing that can confuse sometimes.

Simplified examples:

Because it’s different when negating a combination of LIKE‘s.
Then OR should be used instead.

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