gpt4 book ai didi

mysql - 不是唯一的表/别名

转载 作者:IT老高 更新时间:2023-10-28 23:46:11 25 4
gpt4 key购买 nike

我收到错误 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';

最佳答案

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

试试

    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';

关于mysql - 不是唯一的表/别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8084571/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com