1、使用instr,要注替换掉符号:单引号(单引号替换成两个单引号), 如:如要在字段col1中模糊查询单引号: select * from test t where instr(t.col1,'''')>0;2、使用like:注意在前台要替换掉的字符(使用\作escape字符),单引号、\、_、%号 如要在字段col1中模糊查询“\'_%'字符串(单引号替换成双单引号,其它特殊字符前加上\), 替换后的SQL语句如下: select * from test t where t.col1 like '%\\''\_\%%' escape '\';
like 加正则表达式就可以了
select * from emp where ename like '%\_%' escape '\'; select * from emp where ename like '%u_%' escape 'u'; .....转义字符可以自定义的
如:如要在字段col1中模糊查询单引号:
select * from test t where instr(t.col1,'''')>0;2、使用like:注意在前台要替换掉的字符(使用\作escape字符),单引号、\、_、%号
如要在字段col1中模糊查询“\'_%'字符串(单引号替换成双单引号,其它特殊字符前加上\),
替换后的SQL语句如下:
select * from test t where t.col1 like '%\\''\_\%%' escape '\';
select * from emp where ename like '%u_%' escape 'u';
.....转义字符可以自定义的