Jump to content

Help simplifying query


HDFilmMaker2112

Recommended Posts

Would there be a way to simplify the following, so it's not got the while loop in it?

$sql_average_rating="SELECT product_id, (SUM(review_product_rating)/(COUNT(review_product_rating)-1)) AS review_product_rating FROM $tbl_name3 GROUP BY product_id";
$results_average_rating=mysql_query($sql_average_rating);
while($row_average_rating=mysql_fetch_array($results_average_rating)){
extract($row_average_rating);
$sql_insert_rating="UPDATE $tbl_name product_rating_average='$review_product_rating' WHERE product_id='$product_id'";
mysql_query($sql_insert_rating);
}

Link to comment
https://forums.phpfreaks.com/topic/238717-help-simplifying-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.