触发器的IF语法在以下程序中意味着什么?

时间:2011-04-11 06:26:28

标签: mysql sql triggers mysql5

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 ;  

我在理解这个触发器语句时遇到了一些问题。你能解释一下这个陈述吗?

if new.id_category in ('list','of','special','categories')

语句意思是??

1 个答案:

答案 0 :(得分:2)

new.id_category = 'list'
or
new.id_category = 'of'
or
new.id_category = 'special'
or
new.id_category = 'categories'