title: Mysql Select row, update values and insert into another table
body: <p>I have a temporary table with some rows:</p>
  
  <pre><code>$query = "CREATE TEMPORARY TABLE {$tn} (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `type` varchar(255) NOT NULL,
    `title` varchar(255) DEFAULT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB";
  </code></pre>
  
  <p>I would like to select each row in this table, nulify id, update 'type' (for example) and insert whole selected row into another table (which has the same columns as this table).</p>
  
  <p>I tried this but I am getting an error near SET ( You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SET )</p>
  
  <pre><code> foreach ($ids as $id) {//this is each id in temp table
  
      $query = "INSERT INTO $another_table
                SELECT * FROM {$tn} WHERE id='$id'
                SET id=NULL, type='foo'";
  
      $result = $conn-&gt;query($query) or die(mysqli_error($conn)); 
  
  }
  </code></pre>