MySQL: How to escape apostrophe and single quote?

The single quote and apostrophe (s) are commonly used with any kind of text data.

To escape or ignore the single quote is a common requirement for all database developers.
In this post, I am sharing solution for MySQL Database Server.

MySQL Server has actually two options to escape single quote. You can replace single quote to double single quote like (”) and the other is you can use (\’) to escape single quote.

First, Create a sample table:

Insert some sample data with single quote using both (”) and (\’):

To SELECT all data which has ( ‘s ):

The Result:

MySQL Single Quoted

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz