?
Solved

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

Posted on 2011-03-25
4
Medium Priority
?
547 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 2000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

770 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