使用instr函数时,下面的语句可以查到结果
select * from tb_s_order where instr(L300,ordername)>0
而下面的语句不能查到结果
select * from tb_s_order where instr(300,ordername)>0
应该第二条语句查到的记录更多才对,为什么却一条记录都没找到?要怎么样做才可以找到?
select * from tb_s_order where instr(ordername,L300)>0
select * from tb_s_order where instr(ordername,300)>0
呵呵。
直接用like %300%不是更方便?
对呀,你对instr的两参数的先后顺序没找清楚吧
好像用instr会快一点吧
instr不会更快,但是instr的功能不只是这些
他返回的是字符串2在字符串1中出现的位置,如果用 like % 则不能确定
而且instr还有两个参数,分别是从哪一位开始和第几次出现,这都是like不能实现的。