MID
Purpose
This function returns a substring of length length from position position out of the string string.
Syntax
mid::=
Usage notes
-
If
lengthis not specified, all of the characters to the end of the string are used. -
If
positionis negative, counting begins at the end of the string. -
If
positionis 0 or 1, the result begins from the first character of the string. -
If
positionis before the start or after the end of the string, the result isNULL. -
For additional information, refer to the functions RIGHT, LEFT, and REGEXP_SUBSTR.
-
MID is an alias for SUBSTR[ING].
Example
SELECT MID('abcdef',2,3) S1,
MID('abcdef',-3) S2,
MID('abcdef',7) S3,
MID('abcdef',-7) S4
;
Result:
|
S1 |
S2 |
S3 |
S4 |
|---|---|---|---|
|
bcd |
def |
NULL |
NULL |