totn MariaDB Functions

MariaDB: INSTR Function

This MariaDB tutorial explains how to use the MariaDB INSTR function with syntax and examples.

Description

The MariaDB INSTR function returns the location of a substring in a string.

Syntax

The syntax for the INSTR function in MariaDB is:

INSTR( string, substring )

Parameters or Arguments

string
The string to search.
substring
The substring to search for in string.

Note

  • The first position in string is 1.
  • When finding the location of a substring in a string, the INSTR function does not perform case-sensitive search.
  • If substring is not found in string, then the INSTR function will return 0.

Applies To

The INSTR function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB INSTR function examples and explore how to use the INSTR function in MariaDB.

For example:

SELECT INSTR('TechOnTheNet.com', 'T');
Result: 1

SELECT INSTR('TechOnTheNet.com', 't');
Result: 1

SELECT INSTR('TechOnTheNet.com', 'h');
Result: 4

SELECT INSTR('TechOnTheNet.com', '4');
Result: 0