HDFilmMaker2112 Posted June 10, 2011 Share Posted June 10, 2011 I'm looking to know how to tweak this query so it finds the one category with the fewest products in it. mysql_fetch_array(mysql_query("SELECT COUNT(product_id) AS num FROM products")); Link to comment https://forums.phpfreaks.com/topic/239014-select-category-with-fewest-products/ Share on other sites More sharing options...
HDFilmMaker2112 Posted June 10, 2011 Author Share Posted June 10, 2011 I basically need something like this: mysql_fetch_array(mysql_query("SELECT COUNT(product_id) AS num FROM products WHERE product_cat=(SELECT product_cat FROM products WITH LEAST SUM(product_id))")); Link to comment https://forums.phpfreaks.com/topic/239014-select-category-with-fewest-products/#findComment-1228092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.