How to store multiple record in Mysql variable?

How to store the time of creation of record using a trigger/otherwise in Mysql

  • I want to automatically store request_time as the current time when keyword is updated. Here's a sample table: id request_time keyword 1 2011-02-03 8:00:08 free On inserting free, request_time should be set to NOW();. Here's the trigger i have but it doesnt work: delimiter // create trigger ai_update_userinput after update on user_input for each row begin update user_input set request_time = NOW(); end// Help appreciated.

  • Answer:

    That should be possible with a timestamp column, even without a trigger. Take a look at http://dev.mysql.com/doc/refman/5.0/en/timestamp.html in particular the example for the 'on update' clause for the column spec in the table creation.

watkib at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

Timestamp columns already provide this functionality when they have DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP set. See http://dev.mysql.com/doc/refman/5.0/en/timestamp.html.

Lightness Races in Orbit

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.