方法一
用法:
返回值 | 函数名 | 函数说明 |
---|---|---|
int | locate(string substr, string str[, int pos]) | Returns the position of the first occurrence of substr in str after position pos. |
使用案例:
select locate('i','this is china'); --3
select locate('i','this is china',4); --6
select locate('i','this is china',7); --11
方法二
用法:
运算符 | 左右操作数类型 | 函数说明 |
---|---|---|
A REGEXP B | strings | 属于关系运算符,同rlike函数: NULL if A or B is NULL, TRUE if any (possibly empty) substring of A matches the Java regular expression B, otherwise FALSE. For example, ‘foobar’ RLIKE ‘foo’ evaluates to TRUE and so does ‘foobar’ RLIKE ‘^f.*r$’. |
select 'this 是 china' regexp('是'); --true
--以下2种写法等价
select 'this 是 china' regexp('否'); --false
select 'this 是 china' regexp '否'; --false