This tutorial explains how to use the MySQL LOCATE function with syntax and examples.
The MySQL LOCATE function returns the location of the first appearance of a substring in a string.
The syntax for the LOCATE function in MySQL is:
The substring to search for in string.
The string to search.
Optional. The position in string where the search will start. If omitted, it defaults to 1. The first position in the string is 1.
The LOCATE function can be used in the following versions of MySQL:
Let's look at some MySQL LOCATE function examples and explore how to use the LOCATE function in MySQL.
For example: