SELECT *
FROM `choises`
WHERE questionid = :qid
ORDER BY correct DESC, RAND()
LIMIT 5
Forudsat correct
er en slags int. Ellers skal du muligvis ændre DESC
til ASC
.
Du kan 'blande' de 5 resultater ved at bruge et mere ORDER BY RAND()
sådan her:
SELECT * FROM (
SELECT *
FROM `choises`
WHERE questionid = :qid
ORDER BY correct DESC, RAND()
LIMIT 5
) as t
ORDER BY RAND()