- 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
Using LIKE clause twice in a MySQL query
Let us first create a table −
mysql> create table DemoTable2009 ( Name varchar(20) ); Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable2009 values('John Doe'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable2009 values('Adam Smith'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable2009 values('John Smith'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable2009 values('David Miller'); Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable2009;
This will produce the following output −
+--------------+ | Name | +--------------+ | John Doe | | Adam Smith | | John Smith | | David Miller | +--------------+ 4 rows in set (0.00 sec)
Here is the query to use LIKE clause twice in a MySQL query −
mysql> select * from DemoTable2009 where Name like '%Smith%' or Name like '%David%';
This will produce the following output −
+--------------+ | Name | +--------------+ | Adam Smith | | John Smith | | David Miller | +--------------+ 3 rows in set (0.00 sec)
- Related Articles
- Display specific name from a table with repeated individual FirstName and LastName using LIKE clause twice
- Passing an array to a query using WHERE clause in MySQL?
- How Can MySQL GROUP BY clause behave like DISTINCT clause?
- How to use user variables in MySQL LIKE clause?
- MySQL UNION SELECT and IN clause in a single query
- Query for implementing MySQL LIKE as MySQL IN?
- Can we use MySQL GROUP BY clause with multiple columns like MySQL DISTINCT clause is used?
- Can we use “LIKE concat()” in a MySQL query?
- Implement multiple LIKE operators in a single MySQL query
- MySQL LIKE query with dynamic array?
- Implement SELECT LIKE and CHAR_LENGTH() in a single MySQL query
- MySQL query to display records from a table filtered using LIKE with multiple words?
- How can I achieve similar result like using a loop in MySQL WHERE clause to display only alternate ID records?
- Use LIKE % to fetch multiple values in a single MySQL query
- Find the records with % character in a LIKE query with MySQL

Advertisements