Name

RIGHT( )

Synopsis

RIGHT(string, length)

This function returns characters from string given in the first argument for the length specified in the second argument, starting from the right end of the string.

SELECT RIGHT(soc_sec, 4)
FROM students
WHERE student_id = '43325146122';

This SQL statement retrieves the last four digits of the student’s Social Security number as an identity verification.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.