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

Copy single record into another table of like schema

Status
Not open for further replies.

jasonsalas

IS-IT--Management
Jun 20, 2001
480
GU
I've got two tables, TABLE1 and TABLE2. TABLE2 has the exact same columns and data types as TABLE1, with an additional INT column as a foreign key to TABLE1's primary key.

I'm trying to create a homegrown rollback operation wherein when a record is updated in a webpage, the contents of TABLE1 are copied as is into TABLE2, and then TABLE1 will be UPDATE'd.

How can I copy the contents of a record into another table? I was trying the following, but it didn't work:

INSERT INTO TABLE2 (COL1,COL2,COL3) VALUES SELECT COL1,COL2,COL3 FROM TABLE1 WHERE id = '12345'
 
Oops...my bad. I got it. Wrong code in my app. :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top