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")); Quote 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))")); Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.