title: Escaping a single quotation within SQL query
body: <p>I have a table <code>companies</code>, which has two columns named <code>name</code> and <code>address</code>. By running the following code, new data are inserted into the table:</p>
  
  <pre><code>my_name = "my company name"
  my_address = "ABC"
  
  query = "INSERT INTO companies (name,address) VALUES ('#{my_name}','#{my_address}');"
  
  ActiveRecord::Base.connection.execute(query);
  </code></pre>
  
  <p>If I change <code>my_name</code> value from <code>"my company name"</code> to <code>"John's company"</code>, I will get a syntax error. This is because the query becomes:</p>
  
  <pre><code>"INSERT INTO companies (name,address) VALUES ('John's company','ABC');"
  </code></pre>
  
  <p>and <code>'John's company'</code> has a single quotation mark within it.</p>
  
  <p>Given that I have already used double quotation mark for the query string definition, how can I get rid of this error regarding the single quotation mark in my value?</p>