MySQL Forums
Forum List  »  Triggers

Triggers
Posted by: John Loeffler
Date: April 20, 2011 03:17PM

New to MySQL and have created a trigger that updates AFTER an action to a Job table...

drop trigger if exists tsu_resp;
create trigger tsu_resp after update on respondent for each row
update job set ts=current_timestamp;

CREATE TABLE `job` (
`jobnum` int(11) NOT NULL,
`job_name` varchar(100) NOT NULL,
`company` varchar(100) NOT NULL,
`client` varchar(50) default NULL,
`ts` current_timestamp default NULL,
PRIMARY KEY (`jobnum`)) engine=innodb;

CREATE TABLE `respondent` (
`resp_id` bigint(20) NOT NULL,
`stprov_id` int(11) default NULL,
`country_id` int(11) default NULL,
`jobnum` int(11) NOT NULL,
PRIMARY KEY (`resp_id`),
FOREIGN KEY (`jobnum`) references job (`jobnum`)) engine=innodb;


My challenge is that I only want the appropriate jobs current_timestamp updated. Ex., if an UPDATE is made to job number 101 I don't want the current_timestamp(s) updating jobs 102, 103, etc.

Any help would be greatly appreciated!



Edited 1 time(s). Last edit at 04/21/2011 10:53AM by John Loeffler.

Options: Reply• Quote


Subject
Views
Written By
Posted
Triggers
3155
April 20, 2011 03:17PM
1245
April 20, 2011 04:51PM
1603
April 21, 2011 11:03AM
1183
April 21, 2011 01:17PM
1249
April 21, 2011 02:53PM
1163
April 21, 2011 05:16PM
1219
April 21, 2011 07:07PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.