The INSTR function searches for a substring within another string and returns the position of its occurrence in database systems that support the function.
INSTR provides a convenient way to locate characters and substrings during text parsing.
Find the position of a hyphen in a product code.
SELECT
ProductCode,
INSTR(ProductCode, '-') AS HyphenPosition
FROM Products;
INSTR is useful for parsing identifiers, extracting values, and analyzing structured text fields.
- INSTR searches for text within text.
- It returns a position.
- It is useful for parsing strings.
- Syntax varies between databases.
- It can be combined with SUBSTRING.
What is INSTR used for?
INSTR is used to find the position of a substring within another string.
Is INSTR available in every SQL database?
No. Function names and syntax differ between database systems.