Mysql
 sql >> Database >  >> RDS >> Mysql

Ottenere i primi 3 dalla tabella MySQL in base a Condizione/Valore

Bene, puoi provare questo set di query:

(SELECT Name, PositionId, TScore FROM Soccerplayers WHERE PositionID = 1 ORDER BY TScore LIMIT 3)
UNION
(SELECT Name, PositionId, TScore FROM Soccerplayers WHERE PositionID = 2 ORDER BY TScore LIMIT 4)
UNION
(SELECT Name, PositionId, TScore FROM Soccerplayers WHERE PositionID = 3 ORDER BY TScore LIMIT 3)