HDFilmMaker2112 Posted June 7, 2011 Share Posted June 7, 2011 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); } Quote Link to comment https://forums.phpfreaks.com/topic/238717-help-simplifying-query/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.