The RIGHT() function in MySQL is used to extract a specified number of characters from the right (end) side of a string.
Syntax:
RIGHT(string, length)
string: The string from which you want to extract characters.length: The number of characters you want to extract from the right end of the string.
Example Usage:
- Basic Example:
SELECT RIGHT('Hello World', 5);
This will return:
World
- Using with a Column:
SELECT RIGHT(name, 3) FROM employees;
This will extract the last 3 characters from the name column of the employees table.
- Using with a Numeric String:
SELECT RIGHT('123456', 3);
This will return:
456
The RIGHT() function can be useful when you need to extract suffixes or handle right-side substrings of a string.
No comments:
Post a Comment