Question
concat two column in mysql , one of them is an auto-increments, using trigger
Dears, please below is my first trigger to make a column as a concat a two column .. but it is not working ?! can i know where is the error
create table `concatcolumn`(
`id` int(10) AUTO_INCREMENT PRIMARY key,
`org` int(10),
`orgid` int(20) -- this will be a concat column `org` and `id`);
delimiter $$
create trigger concatcolumn_after_insert
AFTER insert on `concatcolumn`
for each row
begin
set new.orgid = concat(new.org,new.id)
end $$
delimiter ;
delimiter $$
create trigger concatcolumn_after_update
AFTER update on `concatcolumn`
for each row
begin
set new.orgid = concat(new.org,new.id)
end $$
delimiter ;
even when I replace AFTER with BEFORE to be
delimiter $$
create trigger concatcolumn_after_insert
before insert on `concatcolumn`
for each row
begin
set new.orgid = concat(new.org,new.id);
end $$;
delimiter ;
I always get the id = 0; enter image description here
any help please ?
filling the column orgid
automatically by concatenate the org
and id
regards