
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find Records with Character in a LIKE Query in MySQL
Let us first create a table −
mysql> create table DemoTable742 (Value varchar(100)); Query OK, 0 rows affected (2.91 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable742 values('632535MIT'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable742 values('US%UK'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable742 values('56%78'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable742 values('%_1234'); Query OK, 1 row affected (0.09 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable742;
This will produce the following output -
+-----------+ | Value | +-----------+ | 632535MIT | | US%UK | | 56%78 | | %_1234 | +-----------+ 4 rows in set (0.00 sec)
Following is the query to find records with % character using LIKE query −
mysql> select *from DemoTable742 where Value LIKE '%\%%';
This will produce the following output -
+--------+ | Value | +--------+ | US%UK | | 56%78 | | %_1234 | +--------+ 3 rows in set (0.00 sec)
Advertisements