title: JSON string - include single quote in MySQL database
body: <p>I have a JSON type filed in a <code>MySQL</code> table. But if the data value contains a single quote, it fails saying bad SQL grammar. Please find the SQL query:</p>
  
  <p>We can resolve this if we add escape character before single quotes. But is there any JSON function available in MYSQL which can be readily used? We have to supply the query from another application written in Java and we would not like to modify the program if possible. </p>
  
  <pre><code>INSERT INTO integration.staging_correspondence_inbound_invoice (correlation_id,interface_name,event_status,event_context,created_by,created_date) values ('1540626495812-0-1','invoice','EXCEPTION_CAUGHT',JSON_ARRAY('[ {
    "exceptionRootCauseMessage" : "UpdateFailedException: Unable to update correspondence for correspondence id '68000'.Exception:{null\n&gt; Record set for Correspondence with ids 68000 contains no records.\n&gt;&gt; }",
    "inExchangeBody" : null,
    "exceptionMessage" : "UpdateFailedException: Unable to update correspondence for correspondence id '68000'.Exception:{null\n&gt; Record set for Correspondence with ids 68000 contains no records.\n&gt;&gt; }"
  }, { }, {
    "EXCEPTION_CAUGHT" : "Unable to update correspondence for correspondence id '68000'.Exception:{null\n&gt; Record set for Correspondence with ids 68000 contains no records.\n&gt;&gt; }"
  } ]'),'Integration_User',NOW())
  </code></pre>
  
  <p>We re using MySQL 5.7. In the above query, <strong><code>"event_context"</code></strong> is the JSON type field.</p>