I would like to query a table, and update the table data, but the data more than 10000 row, so what is the effective way? My code now:
+----+------+---------+
|id | rank | newrank |
+----------------------+
|1 | 1 | 0 |
|2.. | 2 | 0 |
|10000| 10000| 0 |
+----------------------+
//I am using a template language, DB::query = mysqli_query
$ss = DB::fetch_all("SELECT *FROM t1 ORDER BY rank ASC");
$x = 1;
foreach($ss as $sr){
DB::query("UPDATE t1 SET newrank = '".$x."' WHERE id = '".$sr['id']."'");
$x++;
}
Currently I am using the above code, but if data have to update in huge amount, the server will be crashed. Thank you.