This tutorial explains how to use the MySQL POSITION function with syntax and examples.
The MySQL POSITION function returns the location of a substring in a string.
The syntax for the POSITION function in MySQL is:
POSITION( substring IN string )
The substring to search for in string.
The string to search.
The POSITION function can be used in the following versions of MySQL:
Let's look at some MySQL POSITION function examples and explore how to use the POSITION function in MySQL.
For example:
mysql> SELECT POSITION('B' IN 'AODBA.com');
Output: 4
mysql> SELECT POSITION('BA' IN 'AODBA.com');
Output: 4
mysql> SELECT POSITION('Z' IN 'AODBA.com');
Output: 0