gpt4 book ai didi

mysql - 5.5.52-MariaDB 与 5.6.15 mysql 触发器不工作

转载 作者:行者123 更新时间:2023-11-30 21:54:32 25 4
gpt4 key购买 nike

我有一个问题,本地我安装了 5.6.15 mysql,这个触发器正常工作:

BEGIN

IF New.id_category_default = 566
THEN
SELECT COUNT(*) DATA INTO @conta
FROM `lorcustomization_field`
WHERE `id_product` = Old.id_product ;

IF @conta <=0
THEN
INSERT INTO `lorcustomization_field`(`id_product`,`type`,`required`)
VALUES(Old.id_product,1,0);

SELECT `id_customization_field` DATA INTO @idfield FROM `lorcustomization_field`
GROUP BY `id_customization_field` DESC LIMIT 1;


INSERT INTO `lorcustomization_field_lang` (
`id_customization_field`,
`id_lang`,
`id_shop`,
`name`
)
VALUES
(
@idfield ,
1,
1,
'prova'
);

END IF;
END IF;
END

我远程有 5.5.52-MariaDB,触发器在第一个输入遇到其他选择器停止时停止。我哪里错了?

最佳答案

** 改变

  SELECT COUNT(*) DATA INTO @conta
FROM `lorcustomization_field`
WHERE `id_product` = Old.id_product ;

IF @conta <=0
THEN

IF NOT EXISTS( SELECT *
FROM `lorcustomization_field`
WHERE `id_product` = Old.id_product )
THEN

** 改变

   GROUP BY `id_customization_field` DESC LIMIT 1;

   ORDER BY `id_customization_field` DESC LIMIT 1;

** 如果您还没有这些,请添加

INDEX(id_product)
INDEX(id_customization_field)

关于mysql - 5.5.52-MariaDB 与 5.6.15 mysql 触发器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45797849/

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