
- 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
How to escape parentheses in MySQL REGEXP clause and display only specific values with parentheses?
Let us first create a table −
mysql> create table DemoTable1908 ( Code text ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1908 values('MySQL(1)Database'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1908 values('MongoDB 2 Database'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1908 values('MySQL(3)Database'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1908 values('SQL Server(10)Database'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1908 values('MySQL 8 Database'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1908;
This will produce the following output −
+------------------------+ | Code | +------------------------+ | MySQL(1)Database | | MongoDB 2 Database | | MySQL(3)Database | | SQL Server(10)Database | | MySQL 8 Database | +------------------------+ 5 rows in set (0.00 sec)
Here is the query to escape parentheses in a REGEXP clause and display only the paratheses value with () −
mysql> select * from DemoTable1908 where Code regexp '^MySQL[(][0-9][)]Database';
This will produce the following output −
+------------------+ | Code | +------------------+ | MySQL(1)Database | | MySQL(3)Database | +------------------+ 2 rows in set (0.00 sec)
- Related Articles
- Only display specified values inside the IN clause with MySQL?
- MySQL RegExp to fetch records with only a specific number of words
- How to search specific word in MySQL with RegExp?
- Special Syntax with Parentheses in Python
- Generate Parentheses in Python
- Valid Parentheses in C++
- JavaScript: Balancing parentheses
- Count pairs of parentheses sequences such that parentheses are balanced in C++
- MySQL regexp to display only records with strings or strings mixed with numbers. Ignore only the number records
- How to match parentheses in Python regular expression?
- MySQL query to compare and display only the rows with NULL values
- Longest Valid Parentheses in Python
- Remove Invalid Parentheses in C++
- Score of Parentheses in C++
- Cost to Balance the parentheses in C++

Advertisements