MySQL8 INSTR() Functions – String Functions

MySQL INSTR() Functions: Syntax

INSTR ( string, srchstring );

MySQL INSTR() Functions: Description

INSTR() Functions returns the position of the first instance of  srchstring in string. This is the same as the two-argument form of LOCATE(), except that the order of the arguments is opposite.

Note : This function is multibyte safe, and is case-sensitive only if at least one argument is a binary string.

MySQL INSTR() Functions: Parameter

[table caption=”” width=”100%” colwidth=”15%|15%|15%|55%” colalign=”left|left|left|left”]
Name, Required /Optional,Type, Description
string, Required, String , It represents the valid input string.
srchstring, Required, String , It represents valid srchstring to be search for.

MySQL INSTR() Functions: Output

[table caption=”” width=”100%” colwidth=”20%|80%” colalign=”left|left”]
Return, Description
position, the position of the first instance of  srchstring in string.
0, If srchstring is not found in the string.

MySQL INSTR() Functions: Available from

[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, MySQL 4.0

MySQL INSTR() Functions: Example 1

mysql> SELECT INSTR('tutorialmines','mines');
| INSTR('tutorialmines','mines') |
|                              9 |
1 row in set (0.00 sec)

MySQL INSTR() Functions: Example 2

mmysql> SELECT INSTR('tutorialmines','com');
| INSTR('tutorialmines','com') |
| 0 |
1 row in set (0.00 sec)

See all MySQL String functions MySQL 8 String Functions.

Related articles : HEX(), CONCAT(), CONCAT_WS() , LOWER(), UPPER(), LTRIM(), RTRIM().


You may also like...