You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SQL JOIN查询语法错误求助:MySQL报预期输入结束却得到'='

MySQL INNER JOIN语法错误排查与修正

你的查询语句存在两处语法错误,导致MySQL返回指定的语法错误提示:

错误点分析

  • SELECT子句列引用错误:第二行的spherical-realm-388112.Customer_Data.Employees,role 中,表名和列名之间误用了逗号(,),正确的关联符号应为点号(.),即spherical-realm-388112.Customer_Data.Employees.role。
  • JOIN关联条件列引用错误:最后一行的spherical-realm-388112.Customer_Data.departments,department_id 中,同样误用逗号替代了点号,正确写法为spherical-realm-388112.Customer_Data.departments.department_id。

修正后的查询语句

SELECT
`spherical-realm-388112.Customer_Data.Employees`.name,
`spherical-realm-388112.Customer_Data.Employees`.role,
`spherical-realm-388112.Customer_Data.departments`.department_id
FROM
`spherical-realm-388112.Customer_Data.Employees`
INNER JOIN
`spherical-realm-388112.Customer_Data.departments` ON
`spherical-realm-388112.Customer_Data.departments`.department_id = `spherical-realm-388112.Customer_Data.Employees`.department_id

如果想简化语句提升可读性,可以给表设置别名:

SELECT
emp.name,
emp.role,
dept.department_id
FROM
`spherical-realm-388112.Customer_Data.Employees` emp
INNER JOIN
`spherical-realm-388112.Customer_Data.departments` dept ON
dept.department_id = emp.department_id

内容的提问来源于stack exchange,提问作者Hina Saleem

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 22:42:06