Name
POSITION( )
Synopsis
POSITION(substring
INstring
)
This
function returns the numeric starting point from the left of the
first occurrence of the string given in the first argument of the
function found in the string given in the second. MySQL does not
search beyond this point. This function is similar to
LOCATE( )
.
SELECT name_last AS 'Name', POSITION('n' IN name_last) AS 'First n' FROM teachers WHERE teacher_id = '730522'; +--------+---------+ | Name | First n | +--------+---------+ | Vernon | 4 | +--------+---------+
In this SQL statement, the last name of the teacher selected contains the letter “n” twice, but only the position of the first occurrence is returned.
Get MySQL in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.