转义字符%

richer1015 2012-07-10 11:18:02
sprintf(SQL, select * from jgxx where jgbm like '%s%%', jgbm) 假如机构编码为'100', 这样会变成select * from jgxx where jgbm like '100_%', 多了个'_', 原本我想要100%,这种怎么解决,还有就是,如果是2%%,就不会出现这种情况,直接就回变成2%,是较为正常的,这是怎么回事儿呢
...全文
162 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
weedwhim 2012-07-10
  • 打赏
  • 举报
回复
select * from jgxx where jgbm like '%s\%%'escape('\')
horizonlyhw 2012-07-10
  • 打赏
  • 举报
回复

with t as
(
select '123%_323' a from dual
union all
select '1231%%%' a from dual
union all
select '12312312' from dual
)

select t.*
from t
where t.a like '%\_%' escape('\')
or t.a like '%\%%' escape('\')

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧