MySQL选择帮助内连接?

时间:2014-04-22 20:10:39

标签: mysql

我正在编写一个php脚本,显示以下列project_name,customer_name,fName,lName,activeproject。这是我的高级项目的网站的一部分,我真的需要帮助。

我的表格设置如下: 的项目 project_id,project_name,description,custid,projectmgrempid,activeproject

员工 staff_id,fName,lName

客户 cust_id,cust_fname

这就是我所拥有的错误

select t1.project_id, t1.project_name, t1.description, 
t1.custid, t1.projectmgrempid, t1.activeproject, t2.fName, t2.lName, t3.customer_id,    t3.customer_name
from projects t1
inner join employee t2 on t1.projectmgrempid = t2.staff_id
where t1.activeproject = `open`
inner join customer t3 on t1.custid = t3.customer_id;
  

错误是#1064 - 您的SQL语法出错;检查   手册,对应右边的MySQL服务器版本   在t1.custid =上使用near&t;内连接客户t3的语法   t3.customer_id LIMIT 0,30'在第6行

1 个答案:

答案 0 :(得分:0)

您的where子句应出现在您的join子句之后。

select t1.project_id, t1.project_name, t1.description, 
t1.custid, t1.projectmgrempid, t1.activeproject, 
t2.fName, t2.lName, t3.customer_id,    t3.customer_name
from projects t1
inner join employee t2 on t1.projectmgrempid = t2.staff_id
inner join customer t3 on t1.custid = t3.customer_id
where t1.activeproject = 'open';