Curriculum
Course: MYSQL
Login

Curriculum

MYSQL

MySQL References

0/140
Text lesson

RIGHT

Example

Retrieve 4 characters from the right side of a string.

SELECT RIGHT(“SQL Tutorial is cool”, 4AS ExtractString; 

Definition and Usage

The RIGHT() function retrieves a specified number of characters from a string, starting from the right.

Tip: Additionally, consider the LEFT() function for a similar operation.

Syntax

RIGHT(stringnumber_of_chars)

Parameter Values

Parameter

Description

string

Input required: The string from which extraction will be done.

number_of_chars

Input required: The number of characters to be extracted. If this parameter exceeds the number of characters in the string, the function will return the entire string.

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Retrieve 5 characters from the right side of the text in the “CustomerName” column.

SELECT RIGHT(CustomerName, 5AS ExtractString
FROM Customers;