title: Why query inside query is slower than 2 queries in PHP?
body: <p>I have query like this </p>
  
  <pre><code>UPDATE Table2 
     SET status = 2  
     WHERE user_id in (SELECT user_id FROM Table1 WHERE date &gt; 0)
  </code></pre>
  
  <p>It took like 10 seconds to execute
  i break into two queries using php</p>
  
  <pre><code>q1 ="SELECT user_id FROM Table1 WHERE date &gt; 0"
  $q1_res=sql-&gt;execq($q1);
  
  for ($i = 0; $i &lt; count($q1_res); $i++) {
      foreach ($q1_res[$i] as $key =&gt; $value) {
          if ($key === "user_id") {
              $q1_res_ids .= $value . ",";
          }
      }
  }
  
  $q2 ="UPDATE Table2 
         SET status = 2  
         WHERE user_id IN". $q1_res_ids
  $sql-&gt;execq($q2);
  </code></pre>
  
  <p>this took less than 1 second to execute i would think its faster to use MYSQL?</p>