please help as this is turning into a week of almost no sleep already..
I have a table called Products, with these columns: id | productName | category | subcategory | date_added | price .
how can I get the ID and category from the LAST PRODUCT ADDED IN EACH SUBCATEGORY in this table?
so far this kinda works but it only returns the subcategory, and I also need the category and ID
$sql = mysql_query("SELECT DISTINCT subcategory FROM products ORDER BY id DESC LIMIT 12");
If i try something like
$sql = mysql_query("SELECT DISTINCT id, category, subcategory FROM products ORDER BY id DESC LIMIT 12");
it just returns everything..
Thank you all


mysql_-functions, they are outdated, deprecated, and in PHP7 removed. usemysqli_orPDOinstead.