php - Gotta catch all products that have the greatest amount -
with following sample data, need products amount 20 because it's largest quantity. tried query not seem work me because cannot set limit proper amount since not know how many products have quantity.
select * product order quantity desc limit 2 +----+---------+----------+ | id | name | quantity | +----+---------+----------+ | 5 | pencil | 20 | | 8 | stapler | 20 | | 4 | pen | 5 | | 9 | sheet | 3 | +----+---------+----------+ i need products have quantity, not 20, 20 example?
if want select products maximum value of quantity use:
select * product quantity = (select max(quantity) product);
Comments
Post a Comment