0
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')

声明是什么意思??

4

1 回答 1

2
new.id_category = 'list'
or
new.id_category = 'of'
or
new.id_category = 'special'
or
new.id_category = 'categories'
于 2011-04-11T06:30:13.457 回答