sql server - Sql Update - Ambiguous column name -


i have below query update field sku of table o field autosku of table p. , running give me error: "ambiguous column name 'sku'". know problem because engine doesn't know sku talking in condition. need condition make sure each update row mapped correctly. replacing sku o.sku give error "the multi-part identifier "o..sku" not bound.". ideas?

update  o set     sku = p.autosku    o (nolock)         join (nolock) on a.sku = o.sku         join p (nolock) on p.code = a.productcode   o.sku <> p.autosku         , sku = a.sku 

it's due last line - and sku = a.sku need alias first sku column, below:

update  o set     sku = p.autosku    o (nolock)         join (nolock) on a.sku = o.sku         join p (nolock) on p.code = a.productcode   o.sku <> p.autosku         , o.sku = a.sku -- bit redundant 

although @gordonlinoff mentioned, don't need condition in where clause, since have in on clause.


Comments

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -