trigger in 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: how to make trigger in phpmyadmin

ALTER TABLE sales_details
ADD FOREIGN KEY fk_product_code(product_code)
REFERENCES products(product_code)
ON DELETE CASCADE;

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 ;

Tags:

Sql Example