• 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: BINARY

December 20, 2023

MySQL Command: BINARY

MySQL is a popular open-source relational database management system that is widely used for web applications. It provides a wide range of commands and functions to manipulate and query data. One such command is the BINARY command, which is used to perform case-sensitive string comparisons in MySQL.

Understanding Case Sensitivity in MySQL

By default, MySQL performs case-insensitive string comparisons. This means that when you compare two strings, MySQL treats uppercase and lowercase letters as the same. For example, the following query will return a result:

SELECT * FROM users WHERE username = 'john';

Even if the actual value in the database is ‘John’ or ‘JOHN’, MySQL will consider them as a match because it ignores the case.

However, there are scenarios where you may want to perform case-sensitive comparisons. For example, when dealing with usernames or passwords, it is crucial to ensure that the case of the input matches the stored value exactly. This is where the BINARY command comes into play.

Using the BINARY Command

The BINARY command is used to force case-sensitive string comparisons in MySQL. When you use the BINARY command, MySQL treats each character in the string as a binary value, including the case. This means that ‘A’ and ‘a’ are considered different characters.

Here’s an example of how to use the BINARY command:

SELECT * FROM users WHERE BINARY username = 'john';

In this query, the BINARY command is applied to the ‘username’ column. Now, MySQL will only return rows where the ‘username’ value is exactly ‘john’, including the case. If the value is ‘John’ or ‘JOHN’, the query will not return any results.

The BINARY command can also be used in other scenarios, such as sorting data in a case-sensitive manner or performing case-sensitive comparisons in JOIN operations.

Conclusion

The BINARY command in MySQL is a powerful tool for performing case-sensitive string comparisons. It allows you to ensure that the case of the input matches the stored value exactly, which is crucial in certain scenarios such as dealing with usernames and passwords. By using the BINARY command, you can achieve more precise and accurate results in your MySQL queries.

For more information about MySQL and its various commands and functions, consider exploring Server.HK, a leading VPS hosting company that provides reliable and high-performance hosting solutions.

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