作为一个笔记,我已经搜索了很多,但似乎无法掌握如何解决它仍然。我仍然在学习SQL服务器的来龙去脉,请耐心等待。多部分标识符无法绑定异常
我想从两个表获取量的期望输出,但是当我开始子查询加入到我的发言,我会得到这个错误:
The multi-part identifier "OD.Menu Name ID" could not be bound.
这是我的声明。
Select IT.[Item Name], SUM(OD.Quantity) * SI.Quantity as QTY from [Order Detail_T] as OD,
dbo.SumOfIngredientsQty_V as SI
join [Ingredients Qty_T]
on [Ingredients Qty_T].[Menu Name ID] = OD.[Menu Name ID]
join Ingredients_T as It
on [Ingredients Qty_T].[Ingredients ID] = IT.[Ingredients ID]
where SI.Quantity in (Select SumOfIngredientsQty_V.Quantity as SI from SumOfIngredientsQty_V)
Group by IT.[Item Name]
我也创建了一个关联到上述声明一个观点:
create view SumOfIngredientsQty_V
as
Select [Item Name], Sum(Quantity) as Quantity from [Ingredients Qty_T]
join [Ingredients_T]
on [Ingredients Qty_T].[Ingredients ID] = Ingredients_T.[Ingredients ID]
group by [Item Name]
go
有人可以告诉我为什么我会得到“无法绑定”异常。另外如果需要的话,我可以包括表格的关系。
编辑这里有关系(我不能上传图片,但我希望这会做)
Ingredients_T : (PK) Ingredients ID, Item Name
Ingredients Qty_T : (FK) Menu Name ID, (FK) Ingredients ID, Quantity
Menu Name_T : (PK) Menu Name ID, Price, Menu Name
Order Detail_T : (PK) Order Detail ID, (FK) Order ID, (FK) Menu Name ID, Quantity
Ingredients_T > Ingredients Qty_T < Menu Name_T > Order Detail_T
的(<)表示,其中PK去。
@bummi如果它没有列,我将如何去添加列? – YoHanYolo 2014-12-02 18:14:53