Jishay Smallhorn
Jishay Smallhorn

Reputation: 1

Creating trigger to insert from one database table into different database table in PHPMYADMIN

I am using MYSQL in phpmyadmin on a local server. I have two seperate databases with tables ('db1' has 'tb1') AND ('db2' has 'tb2'), I have created a trigger that will insert data inserted on tb1 into tb2. However when I insert data into tb1 the trigger has not done any isert into tb2.

DELIMITER //

CREATE TRIGGER insert_into_tb2_employee 
AFTER INSERT
	ON `db1`.`tb1` FOR EACH ROW

	BEGIN
    	INSERT INTO `db2`.`tb2`
		(badgeNumber,
         firstName,
         lastName,
         SAP,
         email,
         driverLicenceNumber,
         TRN)
         VALUES
         (NEW.badge_number,
          NEW.firstname,
          NEW.lastName,
          NEW.SAP,
          (SELECT `db1`.`email` FROM `db1`.`tb3` WHERE `tb3`.`id`=NEW.id),
          NEW.driver_s_licence_number,
          NEW.tax_registration_number
         );
	END //
    DELIMITER ;

What could be causing this?

Upvotes: 0

Views: 491

Answers (1)

Jishay Smallhorn
Jishay Smallhorn

Reputation: 1

Well, first I tried moving all the tables into db1; still wouldn't work. Then i remembered something about coallation and made sure all table were in utf8_generali. Volia!!! Also tried moving them back into their original places, still wouldn't work :/. Well the first will have to do for now I guess.

Upvotes: 0

Related Questions