jeudi 18 décembre 2014

Update Trigger in MYSQL


Here is my requirement :-


I have a table called "users" and field called "Admin". Field "id" is primary key. Wants to update "Admin" field to "1" if id=1000;


Tried this ,but not working.I tried "New" instead of "old".Also I tried "After" instead of "Before". But it is not working..


Any suggestions please...



DELIMITER $$
CREATE TRIGGER update_user_admin
Before UPDATE ON users
FOR EACH ROW
BEGIN

UPDATE users
SET admin = 0
WHERE old.id = 672;

END;
$$
DELIMITER ;




Aucun commentaire:

Enregistrer un commentaire