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

# instr

> Returns the 1-based character position of the first occurrence of a substring within a string.

This function returns the position where str first appeared in substr (start counting from 1 and measured in characters). If str is not found in substr, then this function will return 0.

## Syntax

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

## Examples

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

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

## keyword

INSTR


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