
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
MySQL query to display records from a table filtered using LIKE with multiple words?
For this, use RLIKE and filter records as in the below syntax &Minus;
select * from yourTableName where yourColumnName rlike 'yourValue1|yourValue2';
Let us first create a table −
mysql> create table DemoTable1935 ( Subject varchar(20) ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1935 values('MySQL'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1935 values('Python'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1935 values('MongoDB'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1935 values('SQL Server'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1935 values('PL SQL'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1935;
This will produce the following output −
+------------+ | Subject | +------------+ | MySQL | | Python | | MongoDB | | SQL Server | | PL SQL | +------------+ 5 rows in set (0.00 sec)
Here is the query to filter records:
mysql> select * from DemoTable1935 where Subject rlike 'SQL|Python';
This will produce the following output −
+------------+ | Subject | +------------+ | MySQL | | Python | | SQL Server | | PL SQL | +------------+ 4 rows in set (0.00 sec)
- Related Articles
- Display selected records from a MySQL table with IN() operator
- MySQL query to display the count of distinct records from a column with duplicate records
- MySQL query to select all the records only from a specific column of a table with multiple columns
- MySQL query to find alternative records from a table
- Use NOT IN, OR and IS NULL in the same MySQL query to display filtered records
- Delete records from a MySQL table with IN() in a single query
- MySQL query to fetch the latest date from a table with date records
- Find the records with % character in a LIKE query with MySQL
- Display table records from a stored procedure in MySQL
- Delete selective multiple records using MySQL DELETE query
- MySQL query to display only 15 words from the left?
- MySQL query to copy records from one table to another with different columns
- A single MySQL query to search multiple words from different column values
- MySQL query to insert multiple records quickly
- Display specific table names with MySQL LIKE Operator

Advertisements