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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -