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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Noob Question on Updating Data

Status
Not open for further replies.

FireFett

Programmer
Mar 31, 2000
42
US
Can some one show me how to make a Update Query that updates values from one table with values from another here is a sample of what I am trying to do.

Table one has the following fields
StorageID
Isle
Row
Bin


Table2 has the following field
ToolID
DestIsle
DestRow
DestBin
StorageID

I need to update table2 with contain the storage ID specified in table 1.
 
DestIsle to Isle
DestRow to Row
DestBin to Bin
 
Code:
UPDATE T1 SET
      T1.StorageID = T2.StorageID
   FROM Table1 T1 INNER JOIN Table2 T2 ON
      T1.Isle = T2.DestIsle
      AND T1.Row = T2.DestRow
      AND T1.Bin = T2.DestBin
 
You don't actually have to do the inner join, you can just reference table 2 in the from clause and use WHERE instead of ON. But if you need to put more conditions on table 1 then now you know how to do it.
 
Your example worked great. Thanks for taking the time answering I got the some of the Basics of SQL but there is much more ground to cover
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top