Mysql 什么触发';如果语法在下面的程序中是什么意思?
我在理解这个触发语句时有点小问题。你能给我解释一下这句话吗Mysql 什么触发';如果语法在下面的程序中是什么意思?,mysql,sql,triggers,mysql5,Mysql,Sql,Triggers,Mysql5,我在理解这个触发语句时有点小问题。你能给我解释一下这句话吗 如果new.id\u类别为('list'、'of'、'special'、'categories') 语句意思???是否有任何方法允许值的范围匹配?比如new.id\u category=1或new.id\u category=2或new.id\u category=3等等??? DELIMITER $$ create trigger mytable_check before insert on test.mytable for ea
如果new.id\u类别为('list'、'of'、'special'、'categories')
语句意思???是否有任何方法允许值的范围匹配?比如new.id\u category=1或new.id\u category=2或new.id\u category=3等等???
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 ;
new.id_category = 'list'
or
new.id_category = 'of'
or
new.id_category = 'special'
or
new.id_category = 'categories'