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

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -