user948438237
user948438237

Reputation: 273

MySQL Trigger Not working

I've created simple trigger to create cloud table (MyISAM table just to perfor FULL TEXT searches) however it's not working (the data is not being added).

DELIMITER ||

DROP TRIGGER IF EXISTS `table_cloud` ||

CREATE TRIGGER `table_cloud` AFTER INSERT ON `table`
FOR EACH ROW 
BEGIN
    INSERT INTO `table_cloud` SELECT `id`, `name`, `description` FROM `table` WHERE id = LAST_INSERT_ID();
END;
||
DELIMITER ;

Any suggestions?

Upvotes: 1

Views: 1101

Answers (1)

manji
manji

Reputation: 47978

Use NEW.ID instead of LAST_INSERT_ID() (NEW contains all columns values of the newly inserted row in 'table')

Upvotes: 1

Related Questions