POSITION

An introduction to the POSITION expression.

POSITION checks for the location of a specified substring in a string value. By itself, it’s not a very useful expression, but it is powerful when combined with the string functions (introduced later in this section). For now, here is a query that returns the number of characters up to and including the space for the first name of each of the sales agents:

SELECT sales_agent,
       POSITION(" " in sales_agent)
  FROM sales_teams

The first several rows of the results table would look like this:

sales_agent position
Anna Snelling 5
Cecily Lampkin 7
Mei-Mei Johns 8
Violet Mclelland 7
Corliss Cosme 8
Rosie Papadopoulos 6
Garret Kinder 7
Wilburn Farren 8
Elizabeth Anderson 10
Daniell Hammack 8
Cassey Cress 7
Donn Cantrell 5
Versie Hillebrand 7