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)
Updated on 26-Jun-2020 12:24:56