mysql - 找不到mySQL请求错误

标签 mysql sql syntax-error

荒谬,但我找不到此请求中的错误

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

什么?

最佳答案

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/

相关文章:

php - CodeIgniter事件记录和AJAX返回所有结果并忽略关键字

mysql - InnoDB 自动操作

sql - 练习 SQL 查询

sql - 如何在查询中使用 (func()).* 语法避免多个函数求值?

mysql - Spring Boot JPA MySQL : Failed to determine a suitable driver class

mysql - 将日期时间字段放入主键会引发 fatal error

mysql - 将 SQL 列类型设置为 varchar(50),只接受整数

sql - SQL逗号错误

R matchingMarkets::hri() x[y] 错误:无效下标类型 'list'

android - 错误 - 没有找到适合 ArrayAdapter 的构造函数