mysql limit inside group?

后端 未结 8 740
粉色の甜心
粉色の甜心 2021-01-13 07:35

I want to limit the size of records inside a group, and here is my trial, how to do it right?

mysql> select * from accounts limit 5 group by type;
         


        
8条回答
  •  梦毁少年i
    2021-01-13 07:36

    I am not sure you can use a limit in the group by. You can probably use it if your group by is a sub select that returns one row/value. For example:

    select * from foo order by (select foo2.id from foo2 limit 1)

    I am just guessing this would work.

提交回复
热议问题