DELIMITER $$
create trigger mytable_check before insert on test.mytable for each row
begin
if new.id_category in ('list','of','special','categories')
and exists
(select * from mytable
where id_category=new.id_category
and keywords=new.keywords) then
call fail(concat('id_category,keywords must be unique when id_category is: ',new.id_category));
end if;
end $$
DELIMITER ;
I am having slight problem in understanding this trigger statement. Can u please explain me this statement?What does
if new.id_category in ('list','of','special','categories')
statement mean??
new.id_category = 'list'
or
new.id_category = 'of'
or
new.id_category = 'special'
or
new.id_category = 'categories'