可笑,但我在此请求中找不到错误

SELECT * FROM diploms
LEFT JOIN student ON diploms.student_id = student.student_id
LEFT JOIN group ON student.group_id = group.group_id
LEFT JOIN speciality ON group.speciality_id = speciality.speciality_id
ORDER BY (CASE WHEN speciality.name IS NULL THEN 1 ELSE 0 END), speciality.name ASC

但是SQL说



什么

最佳答案

groupreserved keyword in MySQL,需要通过反引号进行转义。

SELECT *
FROM diploms
LEFT JOIN student ON diploms.student_id = student.student_id
LEFT JOIN `group` ON student.group_id = `group`.group_id
LEFT JOIN speciality ON `group`.speciality_id = speciality.speciality_id
ORDER BY CASE WHEN speciality.name IS NULL THEN 1 ELSE 0 END,
         speciality.name ASC

关于mysql - 无法找到mySQL请求错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30856372/

10-09 13:48