英文:
JOIN in SQL QUERY
问题
MYSQL返回错误**语法错误:预期输入结束,但得到了“=”在[9:66]**在以下INNER JOIN查询结果中:
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
可以有人帮忙理解错误是什么吗?
我已经尝试多次以不同的方式编写查询,但它不起作用。
英文:
MYSQL is returning error Syntax error: Expected end of input but got "=" at [9:66]
in result if below INNER JOIN Query:
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
Can someone please help to understand what is the error?
I have tried writing the query differently many times but it dosent work.
答案1
得分: 1
你有两个拼写错误,一个在SELECT语句中,一个在ON语句中,你使用了逗号 ,
而不是点号 .
。另外,考虑为表使用别名以提高可读性。
SELECT
EMP.name,
EMP.role,
DEP.department_id
FROM `spherical-realm-388112.Customer_Data.Employees` AS EMP
JOIN `spherical-realm-388112.Customer_Data.departments` AS DEP
ON EMP.department_id = DEP.department_id
英文:
You have two typos, one in the select, one in the ON statement, where you used a ,
instead of a .
. Also consider using aliases for the tables for readability.
SELECT
EMP.name,
EMP.role,
DEP.department_id
FROM `spherical-realm-388112.Customer_Data.Employees` AS EMP
JOIN `spherical-realm-388112.Customer_Data.departments` AS DEP
ON EMP.department_id = DEP.department_id
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论