In this tutorial we will learn how to find occurrence of a string in a string, to do this in MySQL database it provide us with a function INSTR(), it take two arguments first one is haystack or the string from which you wish to find the occurrence of other string, second string is the whom location we are interested in, Please note that the positioned returned will be the starting position of the needle.
INSTR() is multi-byte safe, and is case sensitive only if at least one argument is a binary string.
Method Signature
int INSTR(haystack,needle);
Example 1
SELECT INSTR('foobarbar', 'bar');Output : 4
Example 2
SELECT INSTR('xbar', 'foobar');Output : 0
INSTR() is multi-byte safe, and is case sensitive only if at least one argument is a binary string.
0 comments:
Post a Comment