SUBSTRING(…string-expr…, …int-expr…, …int-expr…)
STRING, int, int -> STRING
The first operand is the original string, and the two others are positions in that string where the substring starts and stops (with the usual convention that start is inclusive and stop is exclusive).
If one of the position is negative then it is meant to be relative to the end of the string.
expression | evaluates to |
---|---|
SUBSTRING("foobar", 2, 4) | "ob" |
SUBSTRING("foobar", -2, 6) | "ar" |
SUBSTRING("foobar", -4, -2) | "ob" |
SUBSTRING("foobar", 20, 40) | "" |
SUBSTRING("foobar", -20, -40) | "" |