MySQL INSTR() Function

The INSTR() function returns the position of the first occurrence of a substring within another string. If the substring is not found, the function returns 0.

Tutorials dojo strip

MySQL INSTR Function Syntax

SQL

MySQL INSTR Function Example

This query tries to find the position of the letter 'a' in the first_name of each patient:

SQL

MySQL INSTR Function Parameters

ParameterDescription
string1The string to be searched
string2The substring to search for within string1

MySQL INSTR Function Doctors Table Example

This query tries to find the position of the letter 'e' in each doctor’s last_name:

SQL

MySQL INSTR Function Notes

  • Returns the position (starting at 1) of the first occurrence of a substring in another string.
  • Returns 0 if the substring is not found.
  • Not available in SQLite or TechKubo Playground.

Tutorials dojo strip