Replaces one or more occurrences of a specified string value with another specified value.

Syntax

RIGHT(expression, numChars)

Arguments

  • expression: a character expression of one of these types, or an expression that resolves to one of these types:
    • CHAR
    • VARCHAR
    • LONG VARCHAR
  • numChars: the number of characters to return, starting from the last (right) position in expression. This value should be an INTEGER.

Returns

  • The same type as the input expression.

  • NULL if expression evaluates to NULL.

Examples

SELECT firstName, RIGHT(firstName, 5) AS firstNameRight5 FROM MYSQL.inventory.cust;

-- VALUES RIGHT('Abraham');
-- Returns 'raham'