SQL INSTR function real usage

In terms of SQL, function means, definitely it returns result. Where as in the WHERE clause we use relational operators (>, <, =, LE, GE) etc. In the where clause, we may or may not get the result. 


You can find Char position in a String

If we want to find a certain character position in a String, we use INSTR function. Look at the syntax.

Syntax for INSTR()

INSTR(Colname, character to which position we need,start position,which char you need)

For example:

 Table Emp-name
Rani Raghav

“Rani Raghav” – I want to find position for first space.

Select INSTR(name, ' ', 1, 1) from emp;

The result will be – 5.