Jump to content

mysql clause


dhimo

Recommended Posts

If it's a recent version of MySQL you can use a subquery. I think this would work.

SELECT * FROM products WHERE product_id IN (SELECT product_id, SUM(quantity) FROM orders GROUP BY product_id ORDER BY SUM(quantity) DESC LIMIT 5      )

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...