I have searched everywhere but couldn't find a viable solution to this. Maybe i'm not going about this the right way. I have a list of comma separeated values in an array of ID's which refrences image_id's in a 'temp_image' table. Now i need to slect all the info about the all the images with image_id's in that array and tranfer them form the 'temp_image' table to the 'images' table.
$IMgids = array(1,2,3,4,5,9); etc how does my query look like? What should my where clause look like. I'm comfortable with transfering one row but in this case it could be as much as 50 rows. Any ideas how i could go about this?
From the little information you posted I'd say you need these two details:
the IN
operator for the WHERE
clause, so that you can reference all entries that are referenced by your array at once: SELECT ... FROM ... WHERE id IN (1,2,3,4,5,9);
. You probably want to construct the id set inside the clause by using phps implode()
function: implode(',',$IMgids)
the sub query principle for inserting multiple rows into a table that are read from another table. Consult the mysql (online) documentation for this. Something like this: INSERT INTO images (SELECT * FROM temp_images WHERE...);