- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
MySQL query to select a specific string with special characters
Let us first create a table −
mysql> create table DemoTable ( Title text ); Query OK, 0 rows affected (0.66 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('MySQL'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('MongoDB\'s'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('MySQL\'s'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Java\'s'); Query OK, 1 row affected (0.24 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+ | Title | +-----------+ | MySQL | | MongoDB's | | MySQL's | | Java's | +-----------+ 4 rows in set (0.00 sec)
Here is the query to select string with special character −
mysql> select *from DemoTable where replace(Title, '''', '') like '%MySQLs%';
This will produce the following output −
+---------+ | Title | +---------+ | MySQL's | +---------+ 1 row in set (0.00 sec)
- Related Articles
- Fetch a specific record from a column with string values (string, numbers and special characters) in MySQL
- MySQL query to retrieve only the column values with special characters?
- MySQL query to remove special characters from column values?
- MySQL query to replace special characters from column value
- Search for specific characters within a string with MySQL?
- MySQL query to split a column after specific characters?
- MySQL SELECT query to return records with specific month and year
- MySQL query to select records beginning from a specific id
- Query in MySQL for string fields with a specific length?
- MySQL query to get all characters before a specific character hyphen
- MySQL regular expression to update a table with column values including string, numbers and special characters
- Search a string with special characters in a MongoDB document?
- How to get a specific column record from SELECT query in MySQL?
- MySQL query to display a substring before a special character in a string
- Insert with a Select query in MySQL

Advertisements