Showing posts with label achive. Show all posts
Showing posts with label achive. Show all posts

Monday, March 12, 2012

Move Row from One table to Another

Hi,
Is there any way i can move a single row to from one table to another [same database].
Basically what i am trying to achive is this. I allow the user to delete a row, but instead of actuall deleting the row, i want to place it into another table [like a recycle bin], which can be restored later.

I know i can simply use insert into statement to add it to the 2nd table and perform the delete statement on table1, but it becomes very tedious becaus there are a lot of fields in my table. I am looking for some other efficient way, if its possible at all.

Any ideas and help is appriciated.

Thanks

DanialOriginally posted by Danial
Hi,
Is there any way i can move a single row to from one table to another [same database].
Basically what i am trying to achive is this. I allow the user to delete a row, but instead of actuall deleting the row, i want to place it into another table [like a recycle bin], which can be restored later.

I know i can simply use insert into statement to add it to the 2nd table and perform the delete statement on table1, but it becomes very tedious becaus there are a lot of fields in my table. I am looking for some other efficient way, if its possible at all.

Any ideas and help is appriciated.

Thanks

Danial

I think the only way to do this to do something like this:

INSERT INTO table2 SELECT * FROM table1 where row = row id.

this will allow you to select all fields without having to type them all. I think this is the most efficent way.|||Thanks, Thats exactly what i was looking for.

Danial