{"id":8504,"date":"2020-11-24T07:44:00","date_gmt":"2020-11-24T07:44:00","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=8504"},"modified":"2025-08-28T04:56:39","modified_gmt":"2025-08-28T04:56:39","slug":"how-to-escape-single-quote-special-characters-in-mysql","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/","title":{"rendered":"How to Escape Single Quote, Special Characters in MySQL"},"content":{"rendered":"\n<p>Sometimes you may need to store single quote, double quote, apostrophe, backticks and other special characters in MySQL columns. But they are also used to enclose strings and characters, as delimiters. So if used as-is, they will confuse MySQL and result in errors. In this article, we will look at how to escape single quote, double quotes, apostrophe, backticks and other special characters.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#How_to_Escape_Single_Quote_Special_Characters_in_MySQL\" >How to Escape Single Quote, Special Characters in MySQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#1_Using_Backslash\" >1. Using Backslash<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#2_Using_Opposite_Quotes\" >2. Using Opposite Quotes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#3_Using_Consecutive_Quotes\" >3. Using Consecutive Quotes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Escape_Single_Quote_Special_Characters_in_MySQL\"><\/span>How to Escape Single Quote, Special Characters in MySQL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here is a simple example to illustrate this problem. When you enter the following query it will not run. Instead, it will expect you to complete the query, due to incomplete single quotes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select 'tes't' as a from sales limit 1;<br>     '&gt;<\/pre>\n\n\n\n<p>Let us say you terminate the query by adding another single quote, you will see the following error message.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">   '&gt; ';<br>ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' as a from sales limit 1;<br>'' at line 1<\/pre>\n\n\n\n<p>There are several simple ways to escape quotes and special characters in MySQL. We will look at eachof these solutions one by one.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Using_Backslash\"><\/span>1. Using Backslash<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can easily escape single quotes, double quotes, apostrophe, backticks and other special characters by adding a backslash (\\) before that character.<\/p>\n\n\n\n<p>Here&#8217;s a MySQL query that escapes single quotes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select 'test\\'s' as test_string;\n+-------------+\n| test_string |\n+-------------+\n| test's      |\n+-------------+<\/pre>\n\n\n\n<p>As you can see the single quote has been escaped and is displayed in query result.<\/p>\n\n\n\n<p>Similarly, here is the MySQL query to escape double quotes<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select 'test\\\"s' as test_string;\n+-------------+\n| test_string |\n+-------------+\n| test\"s      |\n+-------------+<\/pre>\n\n\n\n<p>Similarly, we can use backslash to escape single quotes and double quotes to insert values into MySQL table.<\/p>\n\n\n\n<p>Let us say you have the following table <em>escape_characters_demo(id, string)<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; create table escape_characters_demo(\n       id int,\n       string varchar(255)\n       );<\/pre>\n\n\n\n<p>Now let us try inserting texts with single, backticks and double quotes and their combinations, using backslash.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; mysql&gt; insert into escape_characters_demo(id, string)\n       values(1, 'test\\'s'),\n       (2, 'test\\\"s'),\n       (3, 'test\\`s'),\n       (4, 'test\\'s and best\\'s'),\n       (5, 'test\\\"s and best\\\"s'),\n       (6, 'test\\\"s and best\\'s');\n\nmysql&gt; select * from escape_characters_demo;\n+------+-------------------+\n| id   | string            |\n+------+-------------------+\n|    1 | test's            |\n|    2 | test\"s            |\n|    3 | test`s            |\n|    4 | test's and best's |\n|    5 | test\"s and best\"s |\n|    6 | test\"s and best's |\n+------+-------------------+<\/pre>\n\n\n\n<p>As you can see above, we are able to escape single quotes, double quotes, backticks, multiple single &amp; double quotes, and even a combination of these, by adding a backslash before these special characters. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Using_Opposite_Quotes\"><\/span>2. Using Opposite Quotes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Another method to escape quotes is to enclose them in a set of different quotes. For example, if your text contains single quotes then you can enclose them in double quotes and vice versa. This is because when your text contains single quote and if you enclose them in single quotes then MySQL will see them as 3 single quote, and the second single quote, that is, the one in your text, will be treated as end of single quotes.<\/p>\n\n\n\n<p>On the other hand, when we enclose a text containing single quote within double quotes, then MySQL will treat the double quotes as delimiter and single quote as part of the text.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select \"tes't\" as a from sales limit 1;<br>+-------+<br>| a     |<br>+-------+<br>| tes't |<br>+-------+<br><br>mysql&gt; select 'tes\"t' as a from sales limit 1;<br>+-------+<br>| a     |<br>+-------+<br>| tes\"t |<br>+-------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Using_Consecutive_Quotes\"><\/span>3. Using Consecutive Quotes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes, you may not be able to escape quotes in your string using backslash or you may not be able to use opposite set of quotes. In such cases, you can use two consecutive quotes inside the text instead of one. Here the first quote will escape the second one.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; select 'tes''t' as a from sales limit 1;<br>+-------+<br>| a     |<br>+-------+<br>| tes't |<br>+-------+<br><br>mysql&gt; select \"tes\"\"t\" as a from sales limit 1;<br>+-------+<br>| a     |<br>+-------+<br>| tes\"t |<br>+-------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt 3 different ways to escape single quotes, double quotes and special characters. You can use any of these methods as per your requirement. Hopefully, now you can easily escape special characters in your SELECT, INSERT and UPDATE queries.<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/\">Ubiq<\/a> makes it easy to visualize data, and monitor them in real-time dashboards. <a href=\"https:\/\/ubiq.co\/accounts\/register\">Try Ubiq<\/a> for free.<\/p>\n\n\n\n<p>Also read:<br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-change-default-index-page-in-apache\/\">How to Change Default Index Page in Apache<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-change-default-timezone-in-apache-php\/\">How to Change Default Timezone in Apache\/PHP<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-install-mod_security-on-centos-7\/\">How to Install mod_security on CentOS<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to store string with single quote, double quote, backticks and special characters. Here is how to escape single quote, special characters in MySQL.<\/p>\n","protected":false},"author":1,"featured_media":8506,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[324],"tags":[475],"class_list":["post-8504","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-escape-characters"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Escape Single Quote, Special Characters in MySQL - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you may need to store string with single quote, double quote, backticks and special characters. Here is how to escape single quote, special characters in MySQL.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Escape Single Quote, Special Characters in MySQL - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you may need to store string with single quote, double quote, backticks and special characters. Here is how to escape single quote, special characters in MySQL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-24T07:44:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-28T04:56:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-escape-single-quote-special-characters-mysql.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"730\" \/>\n\t<meta property=\"og:image:height\" content=\"410\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Escape Single Quote, Special Characters in MySQL\",\"datePublished\":\"2020-11-24T07:44:00+00:00\",\"dateModified\":\"2025-08-28T04:56:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/\"},\"wordCount\":548,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/how-to-escape-single-quote-special-characters-mysql.webp?fit=730%2C410&ssl=1\",\"keywords\":[\"escape characters\"],\"articleSection\":[\"MySQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/\",\"name\":\"How to Escape Single Quote, Special Characters in MySQL - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/how-to-escape-single-quote-special-characters-mysql.webp?fit=730%2C410&ssl=1\",\"datePublished\":\"2020-11-24T07:44:00+00:00\",\"dateModified\":\"2025-08-28T04:56:39+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you may need to store string with single quote, double quote, backticks and special characters. Here is how to escape single quote, special characters in MySQL.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/how-to-escape-single-quote-special-characters-mysql.webp?fit=730%2C410&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/how-to-escape-single-quote-special-characters-mysql.webp?fit=730%2C410&ssl=1\",\"width\":730,\"height\":410,\"caption\":\"how to escape single quotes special characters in mysql\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-escape-single-quote-special-characters-in-mysql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Escape Single Quote, Special Characters in MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Escape Single Quote, Special Characters in MySQL - Ubiq BI","description":"Sometimes you may need to store string with single quote, double quote, backticks and special characters. Here is how to escape single quote, special characters in MySQL.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/","og_locale":"en_US","og_type":"article","og_title":"How to Escape Single Quote, Special Characters in MySQL - Ubiq BI","og_description":"Sometimes you may need to store string with single quote, double quote, backticks and special characters. Here is how to escape single quote, special characters in MySQL.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2020-11-24T07:44:00+00:00","article_modified_time":"2025-08-28T04:56:39+00:00","og_image":[{"width":730,"height":410,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-escape-single-quote-special-characters-mysql.webp","type":"image\/webp"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Escape Single Quote, Special Characters in MySQL","datePublished":"2020-11-24T07:44:00+00:00","dateModified":"2025-08-28T04:56:39+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/"},"wordCount":548,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-escape-single-quote-special-characters-mysql.webp?fit=730%2C410&ssl=1","keywords":["escape characters"],"articleSection":["MySQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/","name":"How to Escape Single Quote, Special Characters in MySQL - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-escape-single-quote-special-characters-mysql.webp?fit=730%2C410&ssl=1","datePublished":"2020-11-24T07:44:00+00:00","dateModified":"2025-08-28T04:56:39+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you may need to store string with single quote, double quote, backticks and special characters. Here is how to escape single quote, special characters in MySQL.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-escape-single-quote-special-characters-mysql.webp?fit=730%2C410&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-escape-single-quote-special-characters-mysql.webp?fit=730%2C410&ssl=1","width":730,"height":410,"caption":"how to escape single quotes special characters in mysql"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-escape-single-quote-special-characters-in-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Escape Single Quote, Special Characters in MySQL"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-escape-single-quote-special-characters-mysql.webp?fit=730%2C410&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2da","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=8504"}],"version-history":[{"count":3,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8504\/revisions"}],"predecessor-version":[{"id":9315,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8504\/revisions\/9315"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/8506"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=8504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=8504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=8504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}