当前位置: 代码迷 >> Oracle管理 >> 转义字符%解决方案
  详细解决方案

转义字符%解决方案

热度:57   发布时间:2016-04-24 05:13:03.0
转义字符%
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('\')
  相关解决方案