how to create a trigger in phpmyadmin code example

Example 1: Create Trigger in phpMyAdmin

DROP TRIGGER IF EXISTS testTrigger;
CREATE TRIGGER testTrigger 
BEFORE INSERT ON tbl_table1 
FOR EACH ROW 
BEGIN 
  INSERT INTO tbl_table2 VALUES (NEW.id,NEW.name);
END;

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: 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;

Tags:

Sql Example