gpt4 book ai didi

mysql - 找不到mySQL请求错误

转载 作者:行者123 更新时间:2023-11-29 01:55:15 25 4
gpt4 key购买 nike

荒谬但我找不到这个请求中的错误

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 说

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'group ON student.group_id = group.group_id LIMIT 0, 30' at line 3

什么?

最佳答案

group 是一个 reserved 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com