I got this trigger, I want to evaluate the mobile phone and insert into another table if the regexp returns a value. I’ve tried with this but not success.
delimiter //
create trigger companyA_phones after insert on customer
for each row
begin
set @phone = (select new.phone from customer where new.phone regexp '^0416');
if (@phone) then
insert into company_A(new.id, @phone);
end if;
end//
You don’t make it entirely clear what trouble you are having, but I don’t think you need to be selecting the .new values like that — as they are already available to you. Try something like this:
The need for this trigger does seem to suggest that your underlying schema design is not correctly normalised, so you might want to think about that too.