create trigger phpmyadmin code example
Example 1: Create Trigger in phpMyAdmin
CREATE TRIGGER after_update
AFTER UPDATE ON hodm
FOR EACH ROW
INSERT INTO hodm_log
SET log_action = 'update',
user_name = NEW.user_name,
log_timestamp = NOW();
Example 2: Create Trigger in phpMyAdmin
delimiter
CREATE TRIGGER before_insert_money BEFORE INSERT ON money
FOR EACH
ROW
BEGIN
UPDATE accounts SET balance=10.0;
END;
delimiter ;
Example 3: how to make trigger in phpmyadmin
delimiter
CREATE TRIGGER removeforeing
BEFORE DELETE ON products
FOR EACH ROW BEGIN
DELETE FROM sales_details WHERE product_code = OLD.product_code;
END
delimiter ;
Example 4: Create Trigger in phpMyAdmin
CREATE TRIGGER before_insert_money BEFORE INSERT ON money
FOR EACH ROW UPDATE accounts SET balance=10.0;
Example 5: Create Trigger in phpMyAdmin
CREATE TRIGGER nomCltInsert
BEFORE INSERT ON client
FOR EACH ROW
UPDATE client
SET
NEW.NomClient = UPPER(NEW.NomClient),
NEW.PrenomClient = CONCAT( UPPER( LEFT(NEW.PrenomClient,1) ) , LOWER( SUBSTR( NEW.PrenomClient,2 ) ) );
CREATE TRIGGER nomCltUpdate
BEFORE UPDATE ON client
FOR EACH ROW
UPDATE client
SET
NEW.NomClient = UPPER(NEW.NomClient),
NEW.PrenomClient = CONCAT( UPPER( LEFT(NEW.PrenomClient,1) ) , LOWER( SUBSTR( NEW.PrenomClient,2 ) ) );
Example 6: Create Trigger in phpMyAdmin
delimiter $$
CREATE TRIGGER copy_pid AFTER INSERT on upload FOR EACH ROW
BEGIN
INSERT INTO rating (uid,pid) VALUES (NEW.username,NEW.id);
END$$
delimiter ;