January 10 2013

Mysql instr() Function

Tagged Under : ,

MySQL
Find the string position. I think most of the Software Engineer will use server side script to do it. I also is the one. For PHP, I will use strpos to get the position.

instr(), one of the functions from MySQL which help to solve this problem.

Syntax:
INSTR(str,substr)
Example:
SELECT INSTR('myteststring','st');  
The above statement finds the first occurrence of ‘st’ in ‘myteststring’ at the position 5, and it returns 5.

Make a Comment

You must be logged in to post a comment.