Tuesday, 10 July 2018

Mysql POSITION() function

Mysql POSITION() function

MySQL POSITION() returns the position of a substring within a string.
Syntax:
POSITION(substr IN str)
Arguments
NameDescription
substrA string whose position within another string (str) is to be retrieved.
INKeyword.
strA string within which the position of the substring (substr) is to be retrieved.
The above function is a synonym for LOCATE(substr,str).
MySQL Version: 5.6
Pictorial Presentation
MySQL POSITION() pictorial presentation
Example: MySQL POSITION() function
The following MySQL statement returns the position of the substring ‘ou’ within the string ‘w3resource’
Code:
>SELECT POSITION("ou" IN "w3resource"); 


Sample Output:
mysql> SELECT POSITION("ou" IN "w3resource"); 
+--------------------------------+
| POSITION("ou" IN "w3resource") |
+--------------------------------+
|                              6 | 
+--------------------------------+
1 row in set (0.01 sec)

0 comments:

Post a Comment