gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 09:10:51 24 4
gpt4 key购买 nike

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

声明的意思??

最佳答案

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

关于mysql - 触发器的 IF 语法在以下程序中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5617524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com