I'm trying to add column 'new_id' to a table following the answers on this post.
The objective is to have new_id = 100*id
My SQL version is 5.6.51
This is the query:
ALTER TABLE `mytable`
ADD `new_id` DOUBLE;
CREATE TRIGGER mytrigger BEFORE INSERT ON `mytable`
FOR EACH ROW
BEGIN
SET NEW.`new_id` = COALESCE(NEW.`id`*100);
This is indeed generating a 'new_id' column, but all values are NULL and the error generated is:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4