Jump to content

Multiple Update Vs For Loop


ProblemHelpPlease
 Share

Recommended Posts

I am runing the code below and want to apply the update to multiple fields. I was looking at either having multiple UPDATE's or using an array of fields and a looping the UPDATE. Which is the best option in terms of load on server or is their another way? The code alreay loops through several tables containing several 100,000 rows.

mysql_query("UPDATE $tablename SET NAME = REPLACE(NAME,'?','') WHERE NAME LIKE '%?%'");

Link to comment
Share on other sites

If you're updating the entire table the load on the database is going to be about the same regardless of whether or not you batch the queries. If you want to run them all at once, have the PHP script just print the queries out separated by a semicolon and then paste the entire thing into phpMyAdmin to run them all.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...