我正在尝试将多个表连接在一起,但我似乎无法正确使用它。我得到的错误是:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.egr_name = egr.name
JOIN dirEgr
dirEgr' at line 4
我拥有的SQL sintax是以下
SELECT egr.*, carEgr.*, dirEgr.*, egrEmp.*, emp.*, boss.*, asoci.*, snip.*, pro.*
FROM egr
JOIN carEgr
carEgr.egr_name = egr.name
JOIN dirEgr
dirEgr.egr_name = egr.name
JOIN egrEmp
egrEmp.egr_name = egr.name
JOIN emp
emp.idEmp = egrEmp.emp_idEmp
JOIN boss
boss.emp_idEmp = emp.idEmp
JOIN asosi
asoci.egr_name = egr.name
JOIN snip
snip.egr_name = egr.name
JOIN pro
pro.egr_name = egr.name
除了emp和boss之外,egr_name是大多数表的主键。另外,如何将boss连接到egr表或egr_name主键?我的表是:
egr
name
carEgr
egr_name //primary foreign key from egr table
idCarEgr //primary key
nameCarEgr
dirEgr
idDirEgr //primary key
egr_name //primary foreign key from egr table
nameDirEgr
egrEmp
emp_idEmp //primary key
egr_name //primary foreign key from egr table
nameEmp
emp
idEmp //primary key
nameEmp
boss
idBoss //primary key
emp_idEmp //primary foreign key from emp table
nameBoss
snip
idSNIP //primary key
egr_name //primary foreign key from egr table
nameSNIP
asoci
idAsoci //primary key
egr_name //primary foreign key from egr table
nameAsoci
pro
idPro //primary key
egr_name //primary foreign key from egr table
namePro
答案 0 :(得分:3)
您缺少git stash pop
ON
条款
JOINS
答案 1 :(得分:0)
egrEmp.egr_name = egresado.name
egresado的参考在哪里。这没有定义。除了以上评论之外,请更改此设置并运行您的查询。