How to select data where a field has a min value in MySQL?

后端 未结 7 1300
半阙折子戏
半阙折子戏 2020-12-02 17:02

I want to select data from a table in MySQL where a specific field has the minimum value, I\'ve tried this:

SELECT * FROM pieces WHERE MIN(price)
         


        
7条回答
  •  半阙折子戏
    2020-12-02 17:49

    Efficient way (with any number of records):

    SELECT id, name, MIN(price) FROM (select * from table order by price) as t group by id
    

提交回复
热议问题