Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

INSTR

Example

Find the position of “3” within the string “W3Schools.com” and return its location.

SELECT INSTR(“W3Schools.com”, “3”) AS MatchPosition; 

Definition and Usage

The INSTR() function identifies the position of the initial appearance of one string within another, conducting a search that isn’t case-sensitive.

Syntax

INSTR(string1, string2)

Parameter Values

Parameter

Description

string1

Mandatory: The string to be searched.

string2

Necessary: The string to look for within string1. If string2 isn’t found, this function returns 0.

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Find the position of “COM” within the string “W3Schools.com” and provide its location.

SELECT INSTR(“W3Schools.com”, “COM”) AS MatchPosition; 

Example

Find the position of the character “a” within the CustomerName column and return its location.

SELECT INSTR(CustomerName, “a”)
FROM Customers;