String & Binary Functions (Matching/Comparison)
Returns a rightmost substring of its input.
RIGHT(STR,N) is equivalent to
RIGHT( <expr> , <length_expr> )
The expression for which you want the rightmost substring. The expression must evaluate to a
The length should be an expression that evaluates to an integer. It should specify:
The number of UTF-8 characters to return if the input is
The number of bytes to return if the input is
The length should be greater than or equal to zero. If the length is a negative number, the function returns an empty string.
The data type of the returned value is the same as the data type of the input value (
length_expris greater than the length of
expr, then the function returns
Collation applies to
VARCHARinputs. Collation does not apply if the input data type of the first parameter is
No impact. Although collation is accepted syntactically, collations have no impact on processing. For example, languages with two-character and three-character letters (e.g. “dzs” in Hungarian, “ch” in Czech) still count those as two or three characters (not one character) for the length argument.
The collation of the result is the same as the collation of the input. This can be useful if the returned value is passed to another function as part of nested function calls.
SELECT RIGHT('ABCDEFG', 3); ---------------------+ RIGHT('ABCDEFG', 3) | ---------------------+ EFG | ---------------------+