what is trigger in phpmyadmin code example

Example 1: 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 2: 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 ) ) );

Tags:

Sql Example