首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

转义字符%解决方案

2012-08-07 
转义字符%sprintf(SQL, select * from jgxx where jgbm like %s%%, jgbm)假如机构编码为100, 这样会变

转义字符%
sprintf(SQL, select * from jgxx where jgbm like '%s%%', jgbm) 假如机构编码为'100', 这样会变成select * from jgxx where jgbm like '100_%', 多了个'_', 原本我想要100%,这种怎么解决,还有就是,如果是2%%,就不会出现这种情况,直接就回变成2%,是较为正常的,这是怎么回事儿呢

[解决办法]

SQL code
with t as(select '123%_323' a from dualunion allselect '1231%%%' a from dualunion allselect '12312312' from dual)select t.*from twhere t.a like '%\_%' escape('\') or t.a like '%\%%' escape('\')
[解决办法]
select * from jgxx where jgbm like '%s\%%'escape('\')

热点排行
Bad Request.