ID EN
String Functions and Operators

INSTR(str,substr)

MySQL 8.4

Returns the position of the first occurrence of substring substr in string str. This is the same as the two-argument form of LOCATE(), except that the order of the arguments is reversed.

Syntax

MYSQL
SELECT INSTR('foobarbar', 'bar');
4
SELECT INSTR('xbar', 'foobar');
0

Examples

Example

This function is multibyte safe, and is case-sensitive only if at least one argument is a binary string. If either argument is NULL, this functions returns NULL.

MYSQL
SELECT INSTR('foobarbar', 'bar');
4
SELECT INSTR('xbar', 'foobar');
0