title: How to merge two PDO queries into one?
body: <p>I have two tables named <code>users</code> and <code>contacts</code>. I would like to delete the records from two table at once. For that I am using the code below for now.</p>
  
  <pre><code>public function delete($userId, $contactId) {
      /* Since Values cannot be mixed (the Numbers) with control flow logic          
      (the commas) with prepared statements needs one placeholder per Value. */
      //As many question marks as array entries; the last one needs no comma
      $questionMarks = str_repeat("?,", count($userId)-1)."?";
      $sth = $this-&gt;dbh-&gt;prepare("DELETE FROM users WHERE id IN($questionMarks)");
      $sth-&gt;execute($userId);
  
      $questionMarks = str_repeat("?,", count($contactId)-1) . "?";
      $sth = $this-&gt;dbh-&gt;prepare("DELETE FROM contacts WHERE id IN($questionMarks)");
      $sth-&gt;execute($contactId);
  }
  </code></pre>
  
  <p>Please note that <code>$userId</code> and <code>$contactId</code> will be an array and the count will always be equal.</p>
  
  <p>How do I merge these two queries into one?</p>
  
  <p><strong>ANSWER :</strong> </p>
  
  <p>The below query worked for me.</p>
  
  <pre><code>DELETE users,contacts FROM users INNER JOIN contacts WHERE users.id IN (2) AND contacts.id IN (2);
  </code></pre>