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?
 
Patrick MatthewsConnect With a Mentor Commented:
Hello BoggyBayouBoy,

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

Regards,

Patrick
0
 
ErnariashConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.