Reputation: 2748
So here is what I am trying to do:
Copy every record from one table where the item_id is that of which is in my array.
mysql_query("INSERT INTO archive_items_tb SELECT * FROM item_bank_tb WHERE item_id IN(" . implode(',', $questions) . ")");
$questions
is an array of question ids, parsed to this function.
mysql does not like my attempt, so can somebody please direct to the correct syntax.
thanks
Upvotes: 1
Views: 923
Reputation: 6920
You need to wrap your sub-select in parenthesis. Also, as a note, make sure you escape the values in your $questions
array.
<?php
$query = "INSERT INTO archive_items_tb
(
SELECT * FROM item_bank_tb
WHERE item_id IN (" . implode(',', $questions) . ")
)";
mysql_query($query);
Upvotes: 1