drop table test1;
create table test1(a int, b varchar2(50));
insert into test1 values(1,'nihao %25 haha');
insert into test1 values(1,'nihao ''25'' haha');
commit;
1、查询b列含有%的行
select * from test1
where b like '%\%%' escape '\';
2、查询b列含有单引号'的行
select * from test1
where b like '%''%' escape '\';
create table test1(a int, b varchar2(50));
insert into test1 values(1,'nihao %25 haha');
insert into test1 values(1,'nihao ''25'' haha');
commit;
1、查询b列含有%的行
If you want to find strings containing the % character, you will need to escape the % character within your pattern so that it isn't treated as a wildcard. To do so, you will need to use the ESCAPE clause to let Oracle know which character you have chosen as the escape character:
select * from test1
where b like '%\%%' escape '\';
2、查询b列含有单引号'的行
select * from test1
where b like '%''%' escape '\';
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26521853/viewspace-1255197/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26521853/viewspace-1255197/