i’m trying to update some big table in this way:
<?php
$tables = array("table1","table2","table3","table4","table5");
foreach ($tables as $table) {
$res = mysql_query("SELECT * FROM {$table}");
while($row = mysql_fetch_array($res)){
$data = $row['data'];
$data = gmdate('Y-m-d H:i:s', strtotime($data));
mysql_query("UPDATE {$table} SET data='$data' WHERE user_id='".$row['user_id']."'";);
}
}
?>
Every tables have about 80.000 rows and process will take too much time to finish. How can i solve this using an equivalent function of gmdate in mysql? Thanks! 🙂
you can use mysql’s STR_TO_DATE function to update, use this function in update query. try this
use output ot STR_TO_DATE and put it in the format you needed.
you can use following single update query