mysql -- 字符串子串


LOCATE(substr,str), LOCATE(substr,str,pos)

第一个语法返回substr在字符串str 的第一个出现的位置。第二个语法返回子符串 substr 在字符串str,从pos处开始的第一次出现的位置。如果substr 不在str 中,则返回值为0 。

 
 
mysql> SELECT LOCATE('bar', 'foobarbar');
+---------------------------------------------------------+
| LOCATE('bar', 'foobarbar')                              |
+---------------------------------------------------------+
| 4                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)
原文地址:https://www.cnblogs.com/caer/p/5753081.html