I want to select the most bought items from table orderitems and then get the details of those items and sort DESC
I have the following which returns the most bought items but i can’t figure out how to return the p_name p_price and p_image_path of each item(p_id) from products table
SELECT p_id
, COUNT( p_id ) AS p_id_count
FROM orderitem
GROUP BY p_id
ORDER BY p_id_count $direction
I hope this makes sense
1 Answer