• 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: SUBSTR()

December 20, 2023

MySQL Command: SUBSTR()

MySQL is a popular open-source relational database management system that allows users to store, manage, and retrieve data efficiently. One of the essential functions in MySQL is the SUBSTR() command, which is used to extract a substring from a given string based on specified criteria. In this article, we will explore the various applications and syntax of the SUBSTR() command in MySQL.

Syntax

The syntax for the SUBSTR() command in MySQL is as follows:

SUBSTR(string, start, length)

Here, string is the input string from which the substring will be extracted. start is the position within the string where the extraction should begin, and length is the number of characters to be extracted.

Examples

Let’s look at some examples to understand how the SUBSTR() command works:

Example 1:

SELECT SUBSTR('Hello World', 7);

This query will return the substring starting from the 7th position of the string ‘Hello World’. The result will be ‘World’.

Example 2:

SELECT SUBSTR('MySQL is powerful', 1, 5);

In this example, the query will extract the first 5 characters from the string ‘MySQL is powerful’. The result will be ‘MySQL’.

Example 3:

SELECT SUBSTR('1234567890', 3, 4);

This query will extract a substring starting from the 3rd position of the string ‘1234567890’ and retrieve the next 4 characters. The result will be ‘3456’.

Applications

The SUBSTR() command in MySQL has various applications in data manipulation and analysis. Some common use cases include:

1. Data Extraction

The SUBSTR() command is often used to extract specific portions of a string, such as extracting the domain name from a URL or retrieving the first name from a full name field.

2. Data Validation

By using the SUBSTR() command, you can validate whether a string meets certain criteria. For example, you can check if a credit card number starts with a specific digit or if a phone number has a valid area code.

3. Data Transformation

The SUBSTR() command can be used to transform data by extracting and manipulating specific parts of a string. For instance, you can convert a date string in the format ‘YYYY-MM-DD’ to ‘MM/DD/YYYY’ using the SUBSTR() command.

Summary

The SUBSTR() command in MySQL is a powerful tool for extracting substrings from a given string. It has various applications in data extraction, validation, and transformation. By understanding the syntax and examples provided in this article, you can leverage the SUBSTR() command to manipulate and analyze data effectively.

For more information on VPS hosting solutions, visit Server.HK.

Recent Posts

  • VPS Hosting vs Shared Hosting: Why the Upgrade Is Worth It for Asia-Facing Websites
  • 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

Recent Comments

  1. linezolid cost oral on Top 5 Use Cases for a Hong Kong Dedicated Server in 2026
  2. metoprolol generic on Hong Kong VPS vs Japan VPS: Head-to-Head for Asia-Pacific Deployments in 2026
  3. levitra price on Top 5 Use Cases for a Hong Kong Dedicated Server in 2026
  4. finasterid on Hong Kong VPS vs Singapore VPS: Which Is Better for Your Asia Business in 2026?
  5. doxycycline hyclate 100mg on How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 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