MySQL: RIGHT Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL RIGHT Function

In this guide, we will explain how to use the MySQL RIGHT function with syntax and examples.

Description

The MySQL RIGHT function allows you to extract a substring from a string, starting from the right-most character.

Syntax

The syntax for the RIGHT function in MySQL is:

RIGHT( string, number_of_characters )

Parameters or Arguments

string

The string that you wish to extract from.

number_of_characters

The number of characters that you wish to extract from string starting from the right-most character.

Note

  • If number_of_characters exceeds the length of string, the RIGHT function will return string.

Applies To

The RIGHT function can be used in the following versions :

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

Example

Let’s look at some RIGHT function examples and explore how to use the RIGHT function.

For example:

mysql> SELECT RIGHT('ad gl o b', 1);
Result: 'b'

mysql> SELECT RIGHT('adglob.in', 3);
Result: '.in'

mysql> SELECT RIGHT('adglob.in', 6);
Result: 'lob.in'

mysql> SELECT RIGHT('adglob.in', 100);
Result: 'adglob.in'

Next Topic : Click Here

This Post Has One Comment

Leave a Reply