SUBSTR
All functions > STRING > SUBSTR
Extracts a substring from a string starting at a specified position.
Syntax
SUBSTR(expr, start[, length])
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
string | VARCHAR | Yes | String to extract from |
start | BIGINT | Yes | Starting position (1-indexed, or negative to count from end) |
length | BIGINT | No | Number of characters to extract (optional, defaults to end of string) |
Returns
Extracted substring
Notes
- Start position is 1-indexed
- Negative start position counts from end of string
- If length omitted, extracts to end of string
- If length exceeds remaining string, returns what's available