MySQL RIGHT() Function
Example
Extract a substring from a string (starting from right):
SELECT RIGHT("SQL Tutorial is cool", 4) AS ExtractString;
Try it Yourself »
Definition and Usage
The RIGHT() function extracts a substring from a string (starting from right).
Syntax
RIGHT(string, number_of_chars)
Parameter Values
Parameter | Description |
---|---|
string | Required. The string to extract from |
number_of_chars | Required. The number of characters to extract |
Note
- If number_of_chars exceeds the number of characters in string, the RIGHT() function will return string
Technical Details
Works in: | MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23 |
---|
More Examples
Example
Extract a substring from the text in a column (starting from right):
SELECT RIGHT(CustomerName, 5) AS ExtractString
FROM Customers;
Try it Yourself »