47

我得到错误ERROR 1066 (42000): Not unique table/alias:

我无法弄清楚它有什么问题。

SELECT Project_Assigned.ProjectID, Project_Title, Account.Account_ID, Username, Access_Type
FROM Project_Assigned 
JOIN Account 
  ON Project_Assigned.AccountID = Account.Account_ID
JOIN Project
  ON Project_Assigned.ProjectID = Project.Project_ID
where Access_Type = 'Client';
4

2 回答 2

27

您的查询包含可能在您引用的多个表中具有相同名称的列,因此出现非唯一错误。最好在加入时明确引用和/或使用表别名。

尝试

    SELECT pa.ProjectID, p.Project_Title, a.Account_ID, a.Username, a.Access_Type, c.First_Name, c.Last_Name
      FROM Project_Assigned pa
INNER JOIN Account a
        ON pa.AccountID = a.Account_ID
INNER JOIN Project p
        ON pa.ProjectID = p.Project_ID
INNER JOIN Clients c
        ON a.Account_ID = c.Account_ID
     WHERE a.Access_Type = 'Client';
于 2011-11-10T19:17:22.697 回答
0
 select persons.personsid,name,info.id,address
    -> from persons
    -> inner join persons on info.infoid = info.info.id;
于 2017-07-17T20:37:37.203 回答