转载做备忘记录:
SQL> select * from test;
TEST
——————–
sdd_kk
d’d
dfsfsa
dffa%asfs
12345
1%2345
1%54321
2%54321
%%54321
A&B
已选择9行。
其中包含特殊的字符分别为%,_,&,有可能包含这些字符的数据含有错误,或者需要查找包含这些字符的数据。
SQL> select * from test where test like ‘sdd _%’ escape ‘ ‘;
TEST
——————–
sdd_kk
转义字符为’ ‘(空格);
SQL> select * from test where test like ‘sdd\_%’ escape ‘\’;
TEST
——————–
sdd_kk
转义字符为’\’;
SQL> select * from test where test like ‘sdd=_%’ escape ‘=’;
TEST
——————–
sdd_kk
转义字符为’=’;
SQL> select * from test where test like ‘sdd/_