你好,游客 登录 注册 搜索
背景:
阅读新闻

关于Oracle的where条件有特殊符号的处理

[日期:2013-05-10] 来源:Linux社区  作者:orcldb [字体:大 中 小]

关于Oracle的where条件有特殊符号的处理

有这样的一些数据:
 select 'fie_a' as col from dual
 union all
 select 'fie_b' as col from dual
 union all
 select 'fi_a' as col from dual
 union all
 select 'fi_b' as col from dual;
 
我需要从这些数据中查找fi_开头的数据,一般写法是:
 select *
 from (
      select 'fie_a' as col from dual
      union all
      select 'fie_b' as col from dual
      union all
      select 'fi_a' as col from dual
      union all
      select 'fi_b' as col from dual
 ) t
 where t.col like 'fi_%';
 
但这样写并不能得到我们想要的结果,那么我们需要作如下处理:
 
select *
 from (
      select 'fie_a' as col from dual
      union all
      select 'fie_b' as col from dual
      union all
      select 'fi_a' as col from dual
      union all
      select 'fi_b' as col from dual
 ) t
 where t.col like 'fi\_%' escape '\';

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

linux
相关资讯       Oracle where  Oracle符号 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款