I would like to have a short form of the SQL-command (I am using Oracle SQL)
SELECT * from table1
WHERE field1 not like '%test%'
AND field2 not like '%test%'
AND field3 not like '%test%'
Is there a syntax which is equivalent to that command? I was thinking about something like
SELECT * from table1
WHERE '%test%' not in (field1, field2, field3)
but this syntax unfortunately doesn’t work?! Many thanks for all tips and suggestions.
No, it’s not really possible.
This transformation using one of De Morgan’s laws is very slightly shorter but there’s only a few characters difference:
There is also this hack that is shorter still, but I would advise against it because it will give you a reduction in performance of your query as well as introducing the possiblity of a bug if you change the string literal
'%test%'to something that could contain an underscore, for example'%te_st%':I think what you are already doing is the best solution.