Oracle SQL query not like %

Toronto, 2013.06.10

I learned something from one of our more clever developers today. If you want to do an SQL query of an Oracle database that excludes the '%' character, it's tricky. Whereas the following works on MySQL:

select * from equities where name not like '%%%'

It doesn't work on an Oracle system because % means "match everything" and you haven't properly escaped the middle '%' character in the query. You need:

select * from equities where name not like '%%%' escape ''