INSTR()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns the position of the first occurrence of a substring in another string.
USAGE
INSTR(search_string, substring)
Argument Name | Description |
|---|---|
| The string to search |
| The substring to find |
DETAILS
INSTR() is a string function that returns the position of the first occurrence of substring in the search_string.
The returned value is a 1-relative position when the substring is found or 0 when it is not.
A NULL is returned if any argument is NULL.
EXAMPLES
SELECT INSTR('mariadb', 'a');
+-----------------------+
| INSTR('mariadb', 'a') |
+-----------------------+
| 2 |
+-----------------------+
SELECT INSTR('mariadb', 'ad');
+------------------------+
| INSTR('mariadb', 'ad') |
+------------------------+
| 5 |
+------------------------+
SELECT INSTR('mariadb', 'x');
+-----------------------+
| INSTR('mariadb', 'x') |
+-----------------------+
| 0 |
+-----------------------+
