top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to display previous record value from MySQL database during update?

–1 vote
461 views

I want to update my sql database record and want to populate the value of previous record. So anybody can help me to get the previous value of the record to show when the update require.

posted Apr 17, 2017 by Kavyashree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

You can do that by using the OLD and NEW keywords on a trigger on your table.

Although, i see that you tagged your post as php and I guess you want to get the old value in php, and to do this, you have to do a SELECT before the UPDATE to get the old name, and another SELECT after the UPDATE to get the new name.

answer Jul 19, 2017 by Vipin
Similar Questions
+1 vote

I have a column called name in a table info
So I want to update that with it's current value, like this name + user_input. I tried with this code but not working

mysql_query("UPDATE info SET name = name + '$user_input' WHERE id='$user_id'");

But It returns 0 and update column to 0....

Any idea how to accomplish this task?

0 votes

I have php script form which I used to input Members Details of my system into the MySQL database. My requirement is to display the last member's details in a input box.

0 votes

I wish to delete records in my database that is older than 3 months.

$todays_date = date('Y-m-d');
$old_records_to_delete = ???

if($old_records_to_delete)
{
include(connect.php);
$sql = "DELETE FROM table WHERE date >= '$old_records_to_delete'";
mysql_query($sql, $connect_db) or die(mysql_error());
}

...