请帮忙。我有以下SQL代码,它不断收到错误:
create view vwUpcoming
as
Select a.Auction_ID, b.item_name, b.Item_Description,
b.Item_value, a.Expected_Start_time
from Auction_schedule a
join Item b
on Auction.Item_ID= Item.Item_ID
where a.Expected_Start_Time < CURRENT_TIMESTAMP
错误消息是:
Msg 4104,Level 16,State 1,Line 2
无法绑定多部分标识符“Item.Item_ID” 消息4104,级别16,状态1,行2 无法绑定多部分标识符“Auction.Item_ID”。
答案 0 :(得分:4)
你在这一行上使用了错误的别名:
on Auction.Item_ID= Item.Item_ID
您已将这些表格称为a
或b
,因此您需要引用这些名称,将该行更改为:
on a.Item_ID= b.Item_ID
所以你的完整查询将是:
create view vwUpcoming
as
Select a.Auction_ID, b.item_name, b.Item_Description,
b.Item_value, a.Expected_Start_time
from Auction_schedule a
join Item b
on a.Item_ID= b.Item_ID
where a.Expected_Start_Time < CURRENT_TIMESTAMP