I have an array with 3,000+ rows fomrated like this
$COUNTS = array(
1=>5,
2=>22,
3=>120,
4=>0,
....
);
where the key represents an ID and value is the calculated COUNT…
I need to update all the rows in my table with these new values (with php)…
so right now I am updating them one by one
(simplified) like
foreach($COUNTS as $id=>$count){
mysql_query("UPDATE categories SET count=$count WHERE id=$id");
}
I would need to make 3,000+ queries, to make a simple update….
can this be done in one query or any other less resource consuming way? maybe generating a csv file and updating on the fly or something?
You can try something like