1

Please help. I have the below SQL code and it keeps getting errors:

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

The error message is:

Msg 4104, Level 16, State 1, Line 2
The multi-part identifier "Item.Item_ID" could not be bound.
Msg 4104, Level 16, State 1, Line 2
The multi-part identifier "Auction.Item_ID" could not be bound.

1 Answer 1

4

You are using the wrong aliases on this line:

on Auction.Item_ID= Item.Item_ID 

You have called these tables either a or b so you need to reference those names, change the line to this:

on a.Item_ID= b.Item_ID 

So your full query will be:

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
Sign up to request clarification or add additional context in comments.

2 Comments

Whenever you use an alias in the FROM, you have to continue using that same alias everywhere within the query.
@user1656779 glad it worked, be sure to accept an answer via the checkmark on the left if it was helpful so future visitors can reference it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.