Skip to content
Advertisement

SQL filter out string that matches condition and with specific exception to pass

Sample data

I wanted to filter out all the data that contains test with the exception of one

My expected return result is:

I can code this in PHP like this.

Or in JavaScript like this

But I need it in SQL

Advertisement

Answer

I can see that in your PHP/Js code you’re defining two condition; any value that have ‘test’ in them but not exceptiontestunique. With a specific condition like that, you can achieve with OR. Example:

Demo Fiddle

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