• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

MySQL Command: RIGHT()

December 20, 2023

MySQL Command: RIGHT()

MySQL is a popular open-source relational database management system that is widely used for storing and managing data. It provides a wide range of functions and commands to manipulate and retrieve data efficiently. One such command is RIGHT(), which allows users to extract a specified number of characters from the right side of a string.

Syntax

The syntax for the RIGHT() command is as follows:

RIGHT(string, length)

Here, string is the input string from which you want to extract characters, and length is the number of characters you want to extract from the right side of the string.

Example

Let’s consider an example to understand how the RIGHT() command works:

SELECT RIGHT('Hello World', 5);

The above query will return the last 5 characters from the string ‘Hello World’, which is ‘World’.

Usage

The RIGHT() command can be useful in various scenarios. Here are a few examples:

1. Extracting Last N Characters

Suppose you have a table that stores email addresses, and you want to extract the domain name from each email address. You can use the RIGHT() command to extract the last few characters after the ‘@’ symbol.

SELECT RIGHT(email, LENGTH(email) - INSTR(email, '@')) AS domain FROM users;

In the above query, the RIGHT() command is used to extract the characters after the ‘@’ symbol by subtracting the position of ‘@’ from the total length of the email address.

2. Trimming Leading Zeros

If you have a column that stores numeric values with leading zeros, you can use the RIGHT() command to remove those leading zeros.

SELECT RIGHT(CONCAT('000', number), 3) AS trimmed_number FROM table;

In the above query, the RIGHT() command is used to extract the last 3 characters from the concatenated string, effectively removing the leading zeros.

3. Extracting Substrings

The RIGHT() command can also be used to extract substrings from a larger string based on a specific pattern or delimiter.

SELECT RIGHT(column, LENGTH(column) - INSTR(column, 'delimiter')) AS substring FROM table;

In the above query, the RIGHT() command is used to extract the substring after the specified delimiter by subtracting the position of the delimiter from the total length of the string.

Conclusion

The RIGHT() command in MySQL is a powerful tool for extracting a specified number of characters from the right side of a string. It can be used in various scenarios to manipulate and retrieve data efficiently. By understanding its syntax and usage, you can leverage the RIGHT() command to enhance your MySQL queries and data manipulation tasks.

Summary

In summary, the RIGHT() command in MySQL allows users to extract a specified number of characters from the right side of a string. It is a useful tool for manipulating and retrieving data efficiently. To learn more about VPS hosting solutions, visit Server.HK.

Recent Posts

  • Hong Kong VPS vs Google Cloud Asia: Which Delivers Better China Performance in 2026?
  • Why No-ICP-Filing Hong Kong Hosting Is the Smart Choice for Cross-Border E-Commerce
  • Hong Kong VPS vs AWS Hong Kong Region: Cost, Latency, and Control Compared
  • Data Privacy Laws in Hong Kong: What VPS Users Need to Know
  • Hong Kong VPS Security Checklist: 10 Steps to Harden Your Server in 2026

Recent Comments

  1. metoprolol generic on Hong Kong VPS vs Japan VPS: Head-to-Head for Asia-Pacific Deployments in 2026
  2. levitra price on Top 5 Use Cases for a Hong Kong Dedicated Server in 2026
  3. finasterid on Hong Kong VPS vs Singapore VPS: Which Is Better for Your Asia Business in 2026?
  4. doxycycline hyclate 100mg on How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)
  5. ciprofloxacin 500 mg tablet on How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot