INSTR

Purpose

This function returns the position in string at which search_string appears. If this is not contained, the value 0 is returned.

Syntax

instr::=

Usage Notes

  • The optional parameter position defines from which position the search shall begin (the first character has position 1). If the value is negative, Exasol counts and searches backwards from the end , for example, INSTR( string,'abc',-3) searches backwards from the third last letter.
  • The optional positive number occurrence defines which occurrence shall be searched for.
  • INSTR(string,search_string) is similar to INSTR(string,search_string,1,1).
  • The functions POSITION and LOCATE are similar.

Example

SELECT INSTR('abcabcabc','cab') INSTR1,
       INSTR('user1,user2,user3,user4,user5','user', -1, 2) INSTR2;
Result
INSTR1 INSTR2
3 19