Struck with Updation
This is a discussion on Struck with Updation within the MySQL forums, part of the Database category; I have a table designed named as employee. In that various columns and one of the attributes in these employee ...
-
06-22-2007, 07:07 AM #1
- Join Date
- Apr 2006
- Answers
- 124
Struck with Updation
I have a table designed named as employee. In that various columns and one of the attributes in these employee table is up_date. I am struck with a task namely I want to have this up_date files getting updated with current date as soon as a user updates the table. The column must get updated automatically without any intervention by users. How can I achieve this? Kindly help me out.
-
You can use the triggering concept that will help you to fire the trigger and update the column up_date only when the user updates the table. I have given below the skeleton format of trigger you can make use to finish your process.
CREATE TRIGGER triggername ON databasename.tablename
FOR UPDATE
AS
update tablename
set up_date=getdate()
from tablename
inner join sample on sample.PKCol = tablename.PKCol
In the above the table name for you is employee. The getdate() will help to get the current date inserted into the column up_date on the employee table.


Reply With Quote





