create trigger in phpmyadmin

Solutions on MaxInterview for create trigger in phpmyadmin by the best coders in the world

showing results for - "create trigger in phpmyadmin"
Silvana
03 Mar 2016
1DROP TRIGGER IF EXISTS testTrigger;
2CREATE TRIGGER testTrigger 
3BEFORE INSERT ON tbl_table1 
4FOR EACH ROW 
5BEGIN 
6  INSERT INTO tbl_table2 VALUES (NEW.id,NEW.name);
7END;
Charlie
17 Nov 2016
1delimiter //
2CREATE TRIGGER before_insert_money BEFORE INSERT ON money
3FOR EACH
4ROW
5BEGIN
6    UPDATE accounts SET balance=10.0;
7END;
8//
9delimiter ;
Yannic
23 Feb 2016
1CREATE TRIGGER after_update
2       AFTER UPDATE ON hodm
3       FOR EACH ROW 
4
5       INSERT INTO hodm_log
6       SET log_action = 'update',
7        user_name = NEW.user_name,
8           log_timestamp = NOW();
Alonso
09 Oct 2020
1DELIMITER &&
2 
3CREATE OR REPLACE TRIGGER tr_ajoutHotelResponsable
4BEFORE INSERT ON cpoa.hotels
5FOR EACH ROW
6BEGIN
7    IF(
8        EXISTS(
9            SELECT *
10            FROM cpao.responsables
11            WHERE numResponsable = NEW.numResponsable
12        )
13    )
14    THEN
15        UPDATE cpoa.responsables
16        SET nbHotel = nbHotel + 1
17        WHERE numResponsable = NEW.numResponsable;
18    ELSE
19        INSERT INTO cpao.responsables ( nom, prenom, nbHotels )
20        VALUES ( 'nouveau', 'nouveau', 1 );
21         
22        SET NEW.numResponsable = LAST_INSERT_ID();
23    END IF;
24END&&
25 
26DELIMITER ;
27
Leonie
14 Jun 2018
1CREATE TRIGGER testTrigger 
2BEFORE INSERT ON tbl_table1 
3FOR EACH ROW 
4BEGIN 
5    INSERT INTO tbl_table2 (id,name) values (NEW.id,NEW.name); 
6END
Charles
08 Sep 2017
1CREATE TRIGGER `before_delete` BEFORE DELETE ON `barcode_master` 
2FOR EACH ROW BEGIN 
3UPDATE library_emp_master SET job_type = 1 WHERE barcode_no =   OLD.barcode_no; 
4END;
Amelie
09 Jan 2020
1CREATE TRIGGER before_insert_money BEFORE INSERT ON money
2FOR EACH ROW UPDATE accounts SET balance=10.0;
Silvia
03 Aug 2019
1DELIMITER //
2
3CREATE TRIGGER contacts_after_insert
4AFTER INSERT
5   ON contacts FOR EACH ROW
6
7BEGIN
8
9   DECLARE vUser varchar(50);
10
11   -- Find username of person performing the INSERT into table
12   SELECT USER() INTO vUser;
13
14   -- Insert record into audit table
15   INSERT INTO contacts_audit
16   ( contact_id,
17     created_date,
18     created_by)
19   VALUES
20   ( NEW.contact_id,
21     SYSDATE(),
22     vUser );
23
24END; //
25
26DELIMITER ;
Emma
30 Jun 2018
1CREATE TRIGGER nomCltInsert
2BEFORE INSERT ON client
3FOR EACH ROW
4    UPDATE client
5    SET
6        NEW.NomClient = UPPER(NEW.NomClient),
7        NEW.PrenomClient = CONCAT( UPPER( LEFT(NEW.PrenomClient,1) ) , LOWER( SUBSTR( NEW.PrenomClient,2 ) ) );
8 
9CREATE TRIGGER nomCltUpdate
10BEFORE UPDATE ON client
11FOR EACH ROW
12    UPDATE client
13    SET
14        NEW.NomClient = UPPER(NEW.NomClient),
15        NEW.PrenomClient = CONCAT( UPPER( LEFT(NEW.PrenomClient,1) ) , LOWER( SUBSTR( NEW.PrenomClient,2 ) ) );
16
Eleonora
04 Oct 2018
1delimiter $$
2CREATE TRIGGER copy_pid AFTER INSERT on upload FOR EACH ROW 
3
4BEGIN
5
6INSERT INTO rating (uid,pid) VALUES (NEW.username,NEW.id);
7
8END$$
9delimiter ;