After insert in table_user
, I want the filed user_notification
and user_recover
are null. In this moment, this filed are blank and not null because the form send POST data same blank value.
How to create this trigger?
After insert in table_user
, I want the filed user_notification
and user_recover
are null. In this moment, this filed are blank and not null because the form send POST data same blank value.
How to create this trigger?
I have find a solution:
delimiter $$
create trigger nullify_blanks_ins before insert on your_table
for each row begin
if new.string = '' then
set new.string = null;
end if;
end;
$$
create trigger nullify_blanks_upd before update on your_table
for each row begin
if new.string = '' then
set new.string = null;
end if;
end;
$$
delimiter ;
Ref: Is there a way in MySQL to automatically convert empty string to NULL value?
Thanks for previous Answers.