不用 REGEXP 和 LIKE 如何进行 sql 模糊查询

求教不用REGEXP,LIKE.
来写模糊查询,假设有1完条数据,搜寻

select * from item nick = 'aaaa' where item_title = '护膜'....
阅读 3.4k
1 个回答

INSTR(字段名, 字符串)
返回字符串在某一个字段的内容中的位置, 没有找到字符串返回0,否则返回位置(从1开始)
-- for example
SELECT * FROM item where INSTR(item_title , '护膜' ) > 0
-- instr N
select * from
(select id, instr('护膜,'大宝','护手霜',',item_title +',') as d from
item where item_title in ('护膜','大宝','护手霜') order by d) as t;

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题