- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MySQL select for exact case sensitive match with hyphen in records
For exact case sensitive match, use BINARY after WHERE clause in MySQL. Let us first create a table −
mysql> create table DemoTable -> ( -> EmployeeCode varchar(100) -> ); Query OK, 0 rows affected (0.64 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('EMP-1122'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('emp-1122'); Query OK, 1 row affected (0.43 sec) mysql> insert into DemoTable values('EMP-6756'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('EMP-8775'); Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+--------------+ | EmployeeCode | +--------------+ | EMP-1122 | | emp-1122 | | EMP-6756 | | EMP-8775 | +--------------+ 4 rows in set (0.00 sec)
Following is the query to fetch record with exact case sensitive match −
mysql> select *from DemoTable WHERE BINARY EmployeeCode='EMP-1122';
Output
This will produce the following output −
+--------------+ | EmployeeCode | +--------------+ | EMP-1122 | +--------------+ 1 row in set (0.00 sec)
- Related Articles
- MongoDB query for exact match
- MySQL query to select a record with two exact values?
- How to achieve case sensitive uniqueness and case insensitive search in MySQL?
- Lower case column names with MySQL SELECT?
- How MySQL can perform case-sensitive string comparison?
- Are MySQL database and table names case-sensitive?
- Select records with ACTIVE status in MySQL set with ENUM
- How to make SQL case sensitive string comparison in MySQL?
- Convert the column to a case-sensitive collation in MySQL?
- Case-sensitive sort in JavaScript
- MongoDB query for exact match on multiple document fields
- How to select records beginning with certain numbers in MySQL?
- MySQL query to select records with a particular date?
- How do you force MySQL LIKE to be case sensitive?
- Case sensitive string comparison in Java.

Advertisements