This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME subquery’
错误提示:
This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME subquery’
最近在开发的过程中有这样的一个需求。获取全校前50名学生的各科成绩,首先想到in(…)。sql语句如下:
SELECT
a.`examinee_id`,
a.`subject_id`,
b.`name`,
a.`objective_score`
FROM
e_examinee_exam a
LEFT JOIN d_subject b
ON a.`subject_id` = b.`code`
WHERE a.`parent_exam_id` = 23
AND a.`school_id` = 5200063
AND a.`examinee_id` IN
(SELECT
a.`student_id` AS studentId
FROM
`report_student_total_score` a
WHERE a.parent_exam_id = 23
AND a.`school_id` = 5200063
ORDER BY a.`school_rank`
LIMIT 50)
ORDER BY a.`examinee_id`,
a.`subject_id`;