By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,778 Members | 1,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,778 IT Pros & Developers. It's quick & easy.

Afeter insert trigger

P: 1
Hi

I have the nex table

CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`date_created` date DEFAULT NULL,
`time_created` time DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
`password` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
UNIQUE KEY `password` (`password`),
UNIQUE KEY `password_2` (`password`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=latin1;


I want to create a trigger that after i make an insert into name and passwor columns, it inserte the current date on date_created column, and the current time on time_created column.

Please, can some one help me with this...
Jan 2 '12 #1
Share this Question
Share on Google+
1 Reply


100+
P: 1,059
you dont need a trigger our insert query would be

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO `users` (`date_created`,`time_created`,`name`,`password` 
  2. ) VALUES(DATE(), TIME(), 'chosen Name', password('choosen password'));
  3.  
rest will be done by your auto and defaults
Jan 4 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.