The underline has a meaning similar to the percent sign in the LIKE
condition of SQL. Both are wild characters.
The difference is as follows:
-
% search for zero or more occurrences of any character;
-
_ search for one or more occurrences of any one character.
For example, assuming we have a table with a column named word , and that the table has the following words added:
acata, category, ratchet, eschatology, mercator
Then the results of the queries will be as follows
... where PALAVRA like '%cat%'
-- retorna acata, categoria, catraca, escatologia, mercator
... where PALAVRA like '_cat_'
-- retorna acata
-- Combinando os dois agora:
... where PALAVRA like '%_cat_%'
-- retorna acata, escatologia, mercator
To search for the wildcard characters themselves, you must escape them with a backslash. Your where clause should look like this:
... where NM_CAMPAIGN like '%\_R\_%'
This applies to the three major DBMSs: SQL Server, Oracle and MySql.