trigger phpmyadmin code example

Example 1: Create Trigger in phpMyAdmin

CREATE TRIGGER `before_delete` BEFORE DELETE ON `barcode_master` 
FOR EACH ROW BEGIN 
UPDATE library_emp_master SET job_type = 1 WHERE barcode_no =   OLD.barcode_no; 
END;

Example 2: 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 3: 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 4: Create Trigger in phpMyAdmin

CREATE TRIGGER before_insert_money BEFORE INSERT ON money
FOR EACH ROW UPDATE accounts SET balance=10.0;

Tags:

Sql Example