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

Update Table problem

Status
Not open for further replies.

HeathRamos

IS-IT--Management
Apr 28, 2003
112
0
0
US
I am trying to update a table but I am doing the syntax wrong.
I want to join two tables using a one to one link for 4 fields, after which I
want to update the onhand field of one table with the onhand field of the
other.
Example:
Table1: Field1, Field2, Field3 Field4, Onhand
Table2: Field1, Field2, Field3, Field4, Onhand
I want to join both tables using fields 1-4 and the set the onhand of Table1 to
be the onhand of Table2.
Please help.
 
Hi,

You'll have to use sub-query in the update stmnt,

update table1 a
set a.onhand = ( select b.onhand
from table2 b
where a.field1 = b.field1
and a.field2 = b.field2
and a.field3 = b.field3 )

Assuming that table1 and table2 are having 1:1 relationships.

Regards
Ajay.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top