# INSTR

## Syntax

```sql
INSTR(str,substr)
```

## Description

Returns the position of the first occurrence of substring *substr* in string *str*. This is the same as the two-argument form of [LOCATE()](https://mariadb.com/docs/server/reference/sql-functions/string-functions/locate), except that the order of the arguments is reversed.

`INSTR()` performs a case-insensitive search.

If any argument is `NULL`, returns `NULL`.

## Examples

```sql
SELECT INSTR('foobarbar', 'bar');
+---------------------------+
| INSTR('foobarbar', 'bar') |
+---------------------------+
|                         4 |
+---------------------------+

SELECT INSTR('My', 'Maria');
+----------------------+
| INSTR('My', 'Maria') |
+----------------------+
|                    0 |
+----------------------+
```

## See Also

* [LOCATE()](https://mariadb.com/docs/server/reference/sql-functions/string-functions/locate) ; Returns the position of a string within a string
* [SUBSTRING\_INDEX()](https://mariadb.com/docs/server/reference/sql-functions/string-functions/substring_index) ; Returns the substring from string before count occurrences of a delimiter

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}
