The error format '##keyword' in a lot of docs. This pr is to repair document format. #4335
62 lines
1.7 KiB
Markdown
62 lines
1.7 KiB
Markdown
---
|
|
{
|
|
"title": "locate",
|
|
"language": "zh-CN"
|
|
}
|
|
---
|
|
|
|
<!--
|
|
Licensed to the Apache Software Foundation (ASF) under one
|
|
or more contributor license agreements. See the NOTICE file
|
|
distributed with this work for additional information
|
|
regarding copyright ownership. The ASF licenses this file
|
|
to you under the Apache License, Version 2.0 (the
|
|
"License"); you may not use this file except in compliance
|
|
with the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing,
|
|
software distributed under the License is distributed on an
|
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
KIND, either express or implied. See the License for the
|
|
specific language governing permissions and limitations
|
|
under the License.
|
|
-->
|
|
|
|
# locate
|
|
## description
|
|
### Syntax
|
|
|
|
`INT locate(VARCHAR substr, VARCHAR str[, INT pos])`
|
|
|
|
|
|
返回 substr 在 str 中出现的位置(从1开始计数)。如果指定第3个参数 pos,则从 str 以 pos 下标开始的字符串处开始查找 substr 出现的位置。如果没有找到,返回0
|
|
|
|
## example
|
|
|
|
```
|
|
mysql> SELECT LOCATE('bar', 'foobarbar');
|
|
+----------------------------+
|
|
| locate('bar', 'foobarbar') |
|
|
+----------------------------+
|
|
| 4 |
|
|
+----------------------------+
|
|
|
|
mysql> SELECT LOCATE('xbar', 'foobar');
|
|
+--------------------------+
|
|
| locate('xbar', 'foobar') |
|
|
+--------------------------+
|
|
| 0 |
|
|
+--------------------------+
|
|
|
|
mysql> SELECT LOCATE('bar', 'foobarbar', 5);
|
|
+-------------------------------+
|
|
| locate('bar', 'foobarbar', 5) |
|
|
+-------------------------------+
|
|
| 7 |
|
|
+-------------------------------+
|
|
```
|
|
## keyword
|
|
LOCATE
|