Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How can I search (case-insensitive) in a column using LIKE wildcard?
We can do this with the help of lower() with column name. Firstly, we will create a table with the help of CREATE command.
Creating a table −
mysql> CREATE table InCaseSensDemo -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (0.50 sec)
Inserting records into the table with the help of INSERT command −
mysql> INSERT into InCaseSensDemo values('JOhN');
Query OK, 1 row affected (0.11 sec)
mysql> INSERT into InCaseSensDemo values('bob');
Query OK, 1 row affected (0.21 sec)
mysql> INSERT into InCaseSensDemo values('BoB');
Query OK, 1 row affected (0.13 sec)
mysql> INSERT into InCaseSensDemo values('Bob');
Query OK, 1 row affected (0.18 sec)
Displaying all the records with the help of SELECT command −
mysql> SELECT * from InCaseSensDemo;
The following is the output −
+------+ | Name | +------+ | JOhN | | bob | | BoB | | Bob | +------+ 4 rows in set (0.00 sec)
The syntax to compare case sensitive string in MySQL is as follows −
SELECT * FROM yourTableName WHERE BINARY column_name = 'value';
Now, I am applying the above query to get the result for case sensitive value −
mysql> SELECT * FROM InCaseSensDemo WHERE BINARY Name = 'bob';
The following is the output −
+------+ | Name | +------+ | JOhN | +------+ 1 row in set (0.00 sec)
Advertisements
