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

SQL Update

Status
Not open for further replies.

liuk

Programmer
Jan 16, 2006
54
IT
Hi
I would update a record in my table copying some data from another record within the same table.

For example

TableName : MyTAB
Fields : KeyField,FieldX, FieldY, FieldZ
Value : 1 A B C
2 D E F

I would copy the FieldX and FieldY values from the record 2 in the same field of the record 1 . Is It Possible to do this with a single UPDATE instruction ? Something like


UPDATE MyTab
SET FieldX = T.FieldX,
FieldY = T.FieldY
FROM MyTAB T
WHERE KeyField = 1 and T.KeyField = 2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top