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
It is possible if you are using MariaDB 10.3.3+:
Support for LIMIT clause in GROUP_CONCAT() (MDEV-11297)
SELECT p.id,
GROUP_CONCAT(s.title ORDER BY title SEPARATOR ', ' LIMIT 3) as skills
FROM player p
LEFT JOIN player_skills ps ON ps.player_id = p.id
LEFT JOIN skill s ON s.id = ps.skill_id
WHERE ps.value > 2
GROUP BY p.id
ORDER BY s.id;
db<>fiddle demo