How to escape single quotes in MySQL?

MySQLMySQLi Database

We can escape single quotes with the help of the SELECT statement. For instance, when single quotes are encountered in a name, eg. “Carol’s”.

Let us see the syntax.

SELECT ‘SomeValue’;

Here is an example that display how to include text with single quotes.

mysql> SELECT 'Carol\'s Taylor.';

The following is the output.

+-------------------+
| Carol's Taylor    |
+-------------------+
| Carol's Taylor    |
+-------------------+
1 row in set (0.00 sec)
raja
Published on 20-Nov-2018 06:29:31
Advertisements