title: MYSQLI Prepared Statement Insert and lookup value From other table
body: <p>I have a prepared statement that basically inserts data from an array into the table. but one of the columns I need to get from another table within the database. I came up with this thus far.</p>
  
  <pre><code>$query = "INSERT INTO stockimp si (sku,stock,status,productID) 
            VALUES (?,?,?,(SELECT post_id FROM postmeta pm  
            WHERE si.sku = pm.meta_value AND pm.meta_key = '_sku')) ";
  
  $stmt = $mysqli-&gt;prepare($query);
  $stmt -&gt;bind_param("sss", $dbSKU, $dbStock, $dbStatus);
  $mysqli-&gt;query("START TRANSACTION");
  </code></pre>
  
  <p>It will work fine if I remove the select statement to get the post id and just set it to a static value. But I'm uncertain now at the best approach to take here. I know how to do it if it's just a direct copy of the table but with just grabbing one value from a column I'm not so sure. </p>