webCOMAND

INSTR()

Returns the position of the first occurrence of substring substr in string str. This is the same as the two-argument form of LOCATE(), except that the order of the arguments is reversed.

Prototype

integer INSTR(string $haystack, string $needle)

Parameters

  • haystack - The string that will be searched for needle.
  • needle - The string to search for in haystack.

Return

Return the index of the first occurrence of substring, where 1 is the first character.  Return 0 if it is not found.

Example

SELECT INSTR('John', FullName) AS Index FROM User

Related

FIND_IN_SET()