0
我在我的magento数据库中触发器的语法有些困难。MySQL触发嵌套select语句
我想在创建新地址时更新客户表中的值。
的customer_address_entity_varchar表看起来像这样:
value_id | entity_type_id | attribute_id | entity_id | value
48 | 2 | 28 | 3 | Lancashire
当我没有它的工作原理嵌套的select语句的触发器,所以:
IF (new.attribute_id=28) THEN
UPDATE customer_entity SET customer_entity.group_id = 4
WHERE customer_entity.entity_id = 1
END IF;
我试图使用new.entity_id和新.value从其他表中选择值取代4和1:
DROP TRIGGER IF EXISTS `groupid_update`;
CREATE DEFINER=`rock_store`@`localhost` TRIGGER `groupid_update`
AFTER INSERT ON `customer_address_entity_varchar`
FOR EACH ROW
IF (new.attribute_id = 28) THEN
UPDATE customer_entity
SET customer_entity.group_id = (
SELECT directory_country_region_name.customer_group_id
FROM directory_country_region_name
WHERE directory_country_region_name.name = "'" + new.value + "'")
WHERE customer_entity.entity_id = (
SELECT customer_address_entity.parent_id
FROM customer_address_entity
WHERE customer_address_entity.entity_id = new.entity_id);
END IF;
在MySQL中创建触发器是成功的,但是当我尝试在Magento中添加新地址时,出现一个错误,它告诉我什么都没有。
感谢您的帮助。利亚姆