fbpx

How to bulk update mysql quries

How to bulk update mysql quries

This is a very short and handy mysql query to update all records.
There was a small sql injection in my database and i replaced the specific code from the “tag” and updated all the records.

UPDATE tags SET keywords = REPLACE( keywords, " , ABC.com", ""  )

There was another issue my field type was 150 characters and the sql injection words were striped off so i used php to update all my records.

$r = mysql_query( "select * from tags where keywords like '%';
while ( $o = mysql_fetch_object($r) )
{
    $words_arr = explode(" , keywords );
    Query( "UPDATE tags SET keywords = '".Encode($words_arr[0])."' WHERE id = ".$o->id );
}

 

Share this post