Solved

Insert date into mysql table cell when any cell from same row has been edited

Posted on 2011-03-25
4
497 Views
Last Modified: 2012-08-14
Hi,


I've got column in mysql table called 'date' and I want to have it automatically updated every time I edit any cell in specific row or in other words: every time when some cell has changed. Is there possible to do the following thing in mysql itself?
Example:
before changes:
1 12/01/2010 name surname address
after changes:
1 26/03/2011 sam surname address

In this case I changed 'name' to 'sam' and date has been changed automatically. I can do this in php, but if I can do this in mysql itself, it would save a lot of time, because I have quite many scripts for this table. I use php for editing mysql database.


Thanks for any help.


0
Comment
Question by:Zado
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
Binkers earned 500 total points
Comment Utility
You can use the timestamp data type to automatically keep track of this for you by using the following options when creating your column:
 timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP

See the documentation for more info:  http://dev.mysql.com/doc/refman/5.0/en/timestamp.html
0
 
LVL 8

Author Comment

by:Zado
Comment Utility
Thanks, I'll check that later.
0
 
LVL 2

Expert Comment

by:ASta
Comment Utility
trigger for update?
0
 
LVL 8

Author Closing Comment

by:Zado
Comment Utility
Works perfectly, thanks.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Creating and Managing Databases with phpMyAdmin in cPanel.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now