Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

MySQL POSITION() function

POSITION() function

MySQL POSITION() returns the position of a substring within a string.

Syntax:

POSITION(substr IN str)

Arguments:

Name Description
substr A string whose position within another string (str) is to be retrieved.
IN Keyword.
str A 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

Video Presentation:

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)

All String Functions

MySQL String Functions, slide presentation

Previous: ORD
Next: QUOTE