Pavel Severýn Pavel Severýn - 3 months ago 6
MySQL Question

MySql delete in trigger when value is null or not null

please how can i make in trigger something like this but without IF?? is it possible??

...
IF NEW.value IS NULL THEN
DELETE FROM table WHERE column IS NULL;
ELSE
DELETE FROM table WHERE column=NEW.value;
END IF;

Answer

You can do it in a single statement :

...
DELETE FROM table WHERE column IS NULL OR column=NEW.value;
...