SELECT *
FROM `choises`
WHERE questionid = :qid
ORDER BY correct DESC, RAND()
LIMIT 5
Dengan asumsi correct
adalah semacam int. Jika tidak, Anda mungkin perlu mengubah DESC
ke ASC
.
Anda dapat 'mengacak' 5 hasil menggunakan satu lagi ORDER BY RAND()
seperti ini:
SELECT * FROM (
SELECT *
FROM `choises`
WHERE questionid = :qid
ORDER BY correct DESC, RAND()
LIMIT 5
) as t
ORDER BY RAND()