instr()字符查找函数的使用
文章目录
MySql的sql语句学习之instr()字符查找函数的使用:
INSTR(str,substr)
str:从哪个字符串中搜索
substr:要搜索的子字符串
instr()函数不区分大小写- instr(colName,string1)查询列名包含字符串1的结果,e.g,
select userName from t_user_info where userName like concat("%",'江苏',"%");
与select userName from t_user_info where instr(userName,'江苏');select userName from t_user_info where instr(userName,'江苏')>0;
查询结果相同 - SELECT INSTR(string1,string2)在string1中查找string2字符串并输出下标,e.g,
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论