GROUP_CONCAT with limit

前端 未结 7 1147
甜味超标
甜味超标 2020-11-27 15:34

I have table with player-s in many-to-many relation with skill-s

The goal is to list the players and their \"top 3 skills\" with a single q

7条回答
  •  执念已碎
    2020-11-27 16:18

    There is a much cleaner solution. Wrap it inside another SELECT statement.

    SELECT GROUP_CONCAT(id) FROM (
        SELECT DISTINCT id FROM people LIMIT 4
    ) AS ids;
    
    /* Result 134756,134754,134751,134750 */
    

提交回复
热议问题