title: Mysql variables and multiple queries in PDO. UPDATE query doesn't work
body: <p>I select data from <code>tab1</code> to a variable, and use it in another query, which updates <code>tab1</code>. Target column <code>target</code> is of type INT, so I round it before its set.</p>
  
  <p>It works well in mysql workbench, also getting no error from php (error_reporting set to -1). It just doesn't really update the target column - it stays zero.</p>
  
  <p>Any idea why?</p>
  
  <pre><code>$q = 'SELECT @tmp = ( SELECT t
                        FROM tab1
                        WHERE a_id = :id1 );
        UPDATE tab1
        SET target = ( SELECT ROUND( @tmp / ( SELECT COUNT(*)
                                              FROM tab2
                                              WHERE b_id = :id2 )));
        ';
  
  $sth = $dbh-&gt;prepare( $q );
  $sth-&gt;execute( array( ':id1' =&gt; $id, ':id2' =&gt; $id ) );
  </code></pre>