英文解釋:
It is necessary to use an "escape" character to locate the characters '_' and '%' in a column. The keyword ESCAPE followed by the character used as the delimitor of choice is coded after the string search. For example, '+' is used as the escape character. For example:
SELECT NAME
FROM XYZ_TABLE
WHERE NAME LIKE 'XY+_Z+%BC%'ESCAPE '+'
Result: XY_Z%BCAA
...
XY_Z%BC99
The plus sign '+' can still be used as part of the search string as long as a '+' precedes it. For example:
SELECT NAME
FROM XYZ_TABLE
WHERE NAME LIKE 'XY++Z%' ESCAPE '+'
Result: XY+ZAAAAA
...
XY+Z99999
漢語解釋:
定義:escape關鍵字經常用于使某些特殊字符,如通配符:'%','_'轉義為它們原
來的字符的意義,被定義的轉義字符通常使用'\',但是也可以使用其他的符號。
實例:
SQL> select * from t11 where name like '%_%';
NAME
----------
aa_a
aaa
SQL> select * from t11 where name like '%\_%' escape '\';
NAME
----------
aa_a
注意:如果是 '/' 作為檢索字符, 必須 用 '/' 作為轉義符, 正斜扛也一樣.
select * from wan_test where psid like '%//%' escape '/'