salty
salty

Reputation: 614

multi part identifier can't be bound in an update query

I need to update a table with info from a different table using both tables as the condition

UPDATE prod
SET prod.sale=change.price
WHERE prod.sku=change.sku AND prod.isonsale=0;

Seems straight forward but I keep getting a multi part identifier can't be bound error, looking it up there's a lot of join statements flying about, but not a lot of explanation, can someone tell me why this isn't working and maybe how to fix it?

Thanks!

Upvotes: 0

Views: 72

Answers (1)

Szymon
Szymon

Reputation: 43023

You need to include the change table this way:

UPDATE
    prod
SET
    sale=change.price
FROM
    prod P
INNER JOIN
    change
ON 
    P.someid = change.someid

replace someid with a column name that would join the 2 tables.

Upvotes: 3

Related Questions