Friday, August 6, 2010

Use _ symbol in filtering condition

We know that _ symbol is used as a single character wildcard in Oracle SQL strings comparison. But what if we need it as an actual search pattern, not as a wildcard.

We have to escape it using "escape '\'" operator.


For example:

select '1__2' from dual where '1AA2' like '1\_\_2' escape '\' -> returns "no records found"

select '1__2' from dual where '1AA2' like '1__2' escape '\' -> returns 1 record

0 comments:

Post a Comment