The Idea and Code of Realizing indexOf and lastIndexOf in Oracle SQL

  • 2021-07-10 21:04:39
  • OfStack

When the third parameter of INSTR is 1, the indexOf function is implemented.

When the third parameter of INSTR is-1, the lastIndexOf function is implemented.

For example:

INSTR ('wenjin _ Wen Jin _ Li _ Hao dsf', '_',-1, 1)

The result returned is: 12

INSTR ('wenjin _ Wen Jin _ Li _ Hao dsf', '_', 1, 1)

The return result is: 7

Related articles: