触发器的 IF 语法在以下程序中意味着什么?
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')
语句是什么意思?
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??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)