I have two table Name: registeredList & deregisteredlist. Now when a user getting getting deregistered from “registeredlist” table then a trigger update his info to deregistration table and delete the record from registration table. On my below proc i can update it properly but can’t delete the user from registered table. My proc:
DELIMITER $$
USE `abc_db`$$
DROP TRIGGER `UnsubscriberListTrigger`$$
CREATE
TRIGGER `UnsubscriberListTrigger` AFTER UPDATE ON `registeredlist` FOR EACH ROW
BEGIN
IF (old.SubscriberStatus='registered') THEN
INSERT INTO deregisteredlist(name,SubscriberStatus,DeRegistrationDate)
VALUES(old.name,'Deregistered',NOW());
DELETE from registeredlist where old.id=new.id;/???????/I am getting problem here
END IF;
END $$
DELIMITER ;
Thanks in advance.
I think all you need is to change
WHEREinDELETEstatement.It should go like this:
… because you want to match it against
idcolumn.UPDATE:
Another possibility is this:
– create AFTER INSERT TRIGGER on
deregisteredlistwhich will do the DELETE inregisteredlist. That way you shouldn’t get that error.