ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 用instr替换like提高效率

用instr替换like提高效率

原创 Linux操作系统 作者:wouwouwou 时间:2010-12-18 19:05:18 0 删除 编辑

使用instr函数取代like查询,可提高效率,在海量数据中效果尤其明显。

1.%a%方式:
select * from pub_yh_bm t
where instr(t.chr_bmdm,'2')>0
等份于:
select * from pub_yh_bm t
where t.chr_bmdm like '%2%'

2.%a方式:
select * from pub_yh_bm t
where instr(t.chr_bmdm,'110101')=length(t.chr_bmdm)-length('110101')+1
等份于:
select * from pub_yh_bm t
where t.chr_bmdm like '%110101'

3.a%方式:
select * from pub_yh_bm t
where instr(t.chr_bmdm,'11010101')=1
等份于:
select * from pub_yh_bm t
where t.chr_bmdm like '11010101%'

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24825020/viewspace-682085/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2010-12-09

  • 博文量
    6
  • 访问量
    12283