The LOCATE function returns the position of a substring within another string in database systems that provide this function.
LOCATE helps identify where specific text appears and can be used as part of larger string-processing operations.
Find the location of a domain separator inside an email address.
SELECT
Email,
LOCATE('@', Email) AS AtPosition
FROM Customers;
LOCATE is useful for parsing emails, product codes, account references, and imported text data.
- LOCATE finds a substring position.
- It is useful for text parsing.
- It can support extraction logic.
- Syntax varies between databases.
- It can be combined with string functions.
What does LOCATE do?
LOCATE finds the position of a substring inside another string.
Where is LOCATE useful?
It is useful for parsing structured text such as emails, codes, and identifiers.