Updating one table with values from another

I have the following sql statement and I get a "cannot be bound" error.

update Products
set a.sizeenglish= b.sizeenglish
from Products a , Conversions b
where b.sizedecimal= a.sizedecimal

the conversion table looks like this

1", 2.54
2 3/4", 5.625

the decimal sizes in my products table are already populated.
LVL 1
BoggyBayouBoyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Patrick MatthewsCommented:
Hello BoggyBayouBoy,

UPDATE Products
SET sizeenglish = b.sizeenglish
FROM Products a INNER JOIN
      Conversions b ON a.sizeenglish = b.sizeenglish

Regards,

Patrick
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ErnariashCommented:
BoggyBayouBoy  you almost got it right :) just the alias, the matthewspatrick inner join is better, just review the ON as b.sizedecimal= a.sizedecimal
update a
set sizeenglish= b.sizeenglish
from Products a , Conversions b 
where b.sizedecimal= a.sizedecimal

Open in new window

0
ErnariashCommented:
This is what I meant, and why I like Inner Join statement it makes the code
self-documenting, if you later have to go back and add a LEFT/RIGHT/FULL JOINs
to a third table, it will allow you not to get the mixed-join-types error, but both forms COMMAS and JOINS deliver the same result.
Your error "cannot be bound" is due to the alias your are updating Products and then in your from you have Products as a.. and yo do not need to use the alias in the set ...see set a.sizeenglish...see code :)
 

update a
set sizeenglish= b.sizeenglish
from Products a 
INNER JOIN  Conversions b 
ON b.sizedecimal= a.sizedecimal

Open in new window

0
BoggyBayouBoyAuthor Commented:
Great!! thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.