mysql之locate() 函数

1.含义

locate()函数, 判断字符串中是否包含字符串

2.用法

locate(‘abc’,string)>0  -- 表示string中包含'abc' 字符串 

locate(‘abc’,string)=0  -- 表示string中不包含'abc' 字符串

 一般业务场景中 string 表示具体字段名

3.例子

select * from order where  locate(‘肖’,name)>0  -- 查询订单表中信息,条件是字段(name)中包含‘’肖‘’的字符串

原文地址:https://www.cnblogs.com/dw-date/p/12851303.html