Solved

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

Posted on 2011-03-25
4
524 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
ID: 35217775
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
ID: 35217844
Thanks, I'll check that later.
0
 
LVL 2

Expert Comment

by:ASta
ID: 35222558
trigger for update?
0
 
LVL 8

Author Closing Comment

by:Zado
ID: 35239798
Works perfectly, thanks.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about achieving the basic levels of HRIS security in the workplace.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

816 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

11 Experts available now in Live!

Get 1:1 Help Now