position(substr in str) 是MySQL的一个字符串函数。此方法返回给定子字符串在字符串中的位置。
语法
select position(substr in str)
示例 1
select position('123' in 'yxjc123');
输出:
mysql> select position('123' in 'yxjc123');
+------------------------------+
| position('123' in 'yxjc123') |
+------------------------------+
| 5 |
+------------------------------+
1 row in set (0.00 sec)
示例 2
select position('string' in 'mysql_string_function');
输出:
mysql> select position('string' in 'mysql_string_function');
+-----------------------------------------------+
| position('string' in 'mysql_string_function') |
+-----------------------------------------------+
| 7 |
+-----------------------------------------------+
1 row in set (0.00 sec)