INSTR(string,substr)

Description: Returns the character position of the first occurrence of substr within string, or 0 if it does not occur.

Works the same as LOCATE() with only two arguments, but with the arguments reversed.

Examples:

  • INSTR('Harold Jacobs','a') returns 2.

  • INSTR('Harold Jacobs','JACOBS') returns 8.

  • INSTR('Harold Jacobs',BINARY 'JACOBS') returns 0.

See also: LOCATE()

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.