SQL#1066-不是唯一的表/别名:

时间:2019-04-06 14:00:07

标签: mysql sql phpmyadmin

我的代码出现此错误:

SELECT flatpack_ig,FlatpackID ,Name,Colour,Type,UnitPrice,component_ig,ComponentNo, component_ig,
description FROM flatpack_ig
INNER JOIN flatpackcomponent_ig
ON flatpack_ig, FlatpackID= flatpackcomponent_ig,FlatpackID
INNER JOIN component_ig
ON flatpackcomponent_ig, ComponentNo=component_ig,ComponentNo
ORDER BY flatpack_ig,FlatpackID

2 个答案:

答案 0 :(得分:1)

每当查询中有多个表时,都应始终限定 all 列名。像这样:

SELECT fp.FlatpackID, fp.Name, fp.Colour, fp.Type, fp.UnitPrice,
       c.ComponentNo, c.description
FROM flatpack_ig fp INNER JOIN
     flatpackcomponent_ig fpc
     ON fp.FlatpackID = fpc.FlatpackID INNER JOIN 
     component_ig c INNER JOIN
     flatpackcomponent_ig fpc 
     ON fpc.ComponentNo = c.ComponentNo
ORDER BY fp.FlatpackID;

我猜这些列从哪里来。我的猜测可能不正确。

您的查询还有其他多个问题。我猜这是转录错误-用逗号代替句号和错位的关键字。

答案 1 :(得分:0)

我认为我不确定解决方案

选择flatpack_ig.FlatpackID,名称,颜色,类型,单价,component_ig.ComponentNo,component_ig.Description 从flatpack_ig 内联接flatpackcomponent_ig 开启flatpack_ig.FlatpackID = flatpackcomponent_ig.FlatpackID 内联接component_ig 在flatpackcomponent_ig.ComponentNo = component_ig.ComponentNo