Solved

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

Posted on 2011-03-25
4
539 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP: Filling Out/Creating a PDF 29 102
Generate PDF's using TCPDF - Initial Set Up 9 31
CURL sending XML without spaces PHP 5 34
google retention policy 4 66
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

749 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