STRPOS
All functions > STRING > STRPOS
Returns the position of a substring within a string, optionally finding the N-th occurrence.
Syntax
STRPOS(expr, search, instance)
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
string | VARCHAR | Yes | String to search in |
substring | VARCHAR | Yes | Substring to find |
occurrence | BIGINT | No | Which occurrence to find (1 for first, 2 for second, etc.) - optional |
Returns
Position of the substring (1-indexed), or 0 if not found
Notes
- Position is 1-indexed
- Returns 0 if substring not found
- If occurrence specified, finds N-th occurrence
- Case-sensitive search
- See also: POSITION