Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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)
Advertisements
