> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# instr

> 返回子字符串在字符串中第一次出现的位置（从1开始计数）。

返回 substr 在 str 中第一次出现的位置（从 1 开始计数，按「字符」计算）。如果 substr 不在 str 中出现，则返回 0。

## 语法

```Haskell theme={null}
instr(str, substr)
```

## 参数说明

`str`: 支持的数据类型为 VARCHAR。

`substr`: 支持的数据类型为 VARCHAR。

## 返回值说明

返回值的数据类型为 INT。

## 示例

```Plain Text theme={null}
MySQL > select instr("abc", "b");
+-------------------+
| instr('abc', 'b') |
+-------------------+
|                 2 |
+-------------------+

MySQL > select instr("abc", "d");
+-------------------+
| instr('abc', 'd') |
+-------------------+
|                 0 |
+-------------------+
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.