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

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

Leave a Reply

Be the First to Comment!

Notify of