Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPDATE statement

Status
Not open for further replies.

Shal2

Programmer
Dec 3, 2001
52
NZ
Hello everybody,

I have two tables, table1 and table2. Both have "barcode" column as primary key. Both have also got a column called "Weight"

I want to update "table1", column "Weight" with values from "table2", column "Weight" where the "barcode" of "table1" is equal to "barcode" of "table2".

How can I achieve this with the update statement. The table1 has about 30,000 rows, table2 has about 2000 rows.

Thank you,
Shalini

 
UPDATE table1 SET Weight = table2.Weight
FROM table1
INNER JOIN table2 ON table1.Barcode = table2.Barcode

Zhavic

---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Thank you so much Zhavic,
It worked perfectly.

Also the quote at the end of your message is neat!

Regards,
Shalini.
 
Thanks, glad I could help.

Zhavic


---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top