Damz WildFire Prince
Damz WildFire Prince

Reputation: 11

How to update rows in a database without overwriting previous data

I have a database table that I store patient information in, along with files such as images and Word documents. when updating this table, it overwrites previous data stored. How do I prevent this from happening?

Upvotes: 0

Views: 6765

Answers (1)

Radi
Radi

Reputation: 6604

According to your comment , first you need to backup the old values into other table with same columns data type :

insert into backup_table ( column1 , column2 , ... )
SELECT  column1 , column2 , ...
FROM    orginal_table

then update statement should look like this :

UPDATE orginal_table
SET column1=form_value1, column2=form_value2 ,...
WHERE some_column=some_value

Upvotes: 1

Related Questions