LOCATE() in MySQL — How It Works
What the MySQL LOCATE() function does, with an example.
Published October 19, 2026
LOCATE() returns the position of the first occurrence of a substring within a string, or 0 if not found.
Key points
- Part of standard SQL functions available in MySQL for working with text/strings
Example
SELECT LOCATE('World', 'Hello World'); -- 7