How to find most expensive items in sql with more than one most expensive item?
This will work.
SET @p1 := (SELECT MAX(price) FROM items);SELECT * FROM items WHERE price = @p1;
Using variables, p1
stores the maximum price
from the table items
and then uses the variable p1
in the following query to return all records which have that maximum price without limiting the number of records as you desired.