Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs

MySQL RIGHT Function

by suresh

MySQL Right is one of the String Function, which returns the rightmost characters of the user-specified expression (or column value). This function uses its second argument to decide, How many characters it should return. Let us see how to write MySQL String right Function using Command Prompt, and Workbench with example.

MySQL Right Syntax

The basic syntax of Right in MySQL is as shown below:

SELECT RIGHT (String_Expression, value)
FROM Source

For this string right demo, we are going to use the below shown data

MySQL Right Function Example 1

MySQL Right Example 1

The MySQL string Right function returns the rightmost characters in a given string. The following string function query shows multiple ways to use this Right function.

-- MySQL String Right Example
SELECT RIGHT('Learn MySQL Server', 12) AS `Rightmost Characters`;

SELECT RIGHT('Tutorial Gateway', 7) AS `Rightmost Characters`;

OUTPUT

MySQL RIGHT Example 1

MySQL Right Example 2

The string right in MySQL also allows you to return the rightmost characters of the data inside the columns. In this MySQL example, we are going to find the rightmost characters of all the records present in the Department Name and Email column.

-- MySQL String Right Example
USE mysqltutorial;
SELECT  FirstName, LastName, 
		DepartmentName, 
        RIGHT(DepartmentName, 7) AS `Last 6 Characters in Department`,
        Email,
        RIGHT(Email, 9) AS `Last 9 Characters in Email`
FROM employe
ORDER BY FirstName, LastName;

OUTPUT
MySQL RIGHT Example 2

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy