KB Article #45559

Request with "not like _ % " syntax doesn't work.

Problem

Request with "not like _ %  " syntax doesn't work.


Resolution

The problem is that, under Oracle, the underscore (_) is a character that replaces any character.
So a criteria with : "not like _%" is searching for any character, followed by any string.

To make a search including the underscore character, it is necessary ot use the following syntax:

select * from like_escape_test where some_text not like '\_%' escape '\'

With this syntax, the underscore is not treated as the character that replaces any character but as a string.
In fact, the escape function will define the character \ as the escape character. Only one length character can be defined as the escape character.