Mysql字符串位置函数locate,可检测是否包含字符串

来源:互联网 发布:java wait 异常 编辑:程序博客网 时间:2024/05/29 06:55
  •  LOCATE(substr,str)LOCATE(substr,str,pos)

    The first syntax returns the position of the first occurrence of substring substr in string str. The second syntax returns the position of the first occurrence of substring substr in string str, starting at position pos. Returns 0 if substr is not in str.

    mysql> SELECT LOCATE('bar', 'foobarbar');        -> 4mysql> SELECT LOCATE('xbar', 'foobar');        -> 0mysql> SELECT LOCATE('bar', 'foobarbar', 5);        -> 7

    This function is multibyte safe, and is case-sensitive only if at least one argument is a binary string.

0 0
原创粉丝点击