I have a table which contains ratings of buyers who are in thousands. I use a form with radio buttons to change rating for each buyer. After submitting I have an array where index is $buyer_id and value is $new_rating. Since, I change the rating more than times a month, it's not big deal, but I would like to know what is better solution. I have a three queries like below:

$SQL_1 = "UPDATE buyers SET rating='R'WHERE buyer_id=1 OR buyer_id=5 
          OR buyer_id=8 OR buyer_id=23 OR ... OR buyer_id=1786";


$SQL_2 = "UPDATE buyers SET rating='A' WHERE buyer_id=2 OR buyer_id=3 
          OR buyer_id=9 OR buyer_id=18 OR ... OR buyer_id=1823";


$SQL_3 = "UPDATE buyers SET rating='NR' WHERE buyer_id=4 OR buyer_id=6 
          OR buyer_id=7 OR buyer_id=21  OR ... OR buyer_id=1824";


or like below for each record:

mysql_query("UPDATE buyers SET rating='R' WHERE buyer_id=1"); 
mysql_query("UPDATE buyers SET rating='A' WHERE buyer_id=2"); 
mysql_query("UPDATE buyers SET rating='A' WHERE buyer_id=3"); 
mysql_query("UPDATE buyers SET rating='NR' WHERE buyer_id=4");


Posted in: MySQL

Related FAQ's

Marius Ion ANGEL HOT SOFT LLC (800) 316-7677