Yasen Ivanov
Yasen Ivanov

Reputation: 1023

MySQL trigger before insert - truncated incorrect DOUBLE error

I want to concatenate the new username with string and I have the following trigger:

CREATE DEFINER=`root`@`localhost` TRIGGER `rating_platform`.`admins_BEFORE_INSERT` BEFORE INSERT ON `admins` FOR EACH ROW
BEGIN
SET NEW.username = NEW.username + "test";
END

I receive this error:

ERROR 1292: 1292: Truncated incorrect DOUBLE value: 'test'

What am I doing wrong?

Upvotes: 0

Views: 178

Answers (1)

Pavel Katiushyn
Pavel Katiushyn

Reputation: 825

Use CONCAT function:

SET NEW.username = CONCAT(NEW.username,"test");

Upvotes: 2

Related Questions