用参数编写mysql触发器

时间:2017-03-26 12:55:23

标签: mysql triggers prestashop-1.6 eventtrigger database-trigger

这是在mysql中编写触发器的方法吗?

DELIMITER //

CREATE TRIGGER metKeywords_after_insert AFTER
UPDATE
ON
  ps_product_lang FOR EACH ROW
BEGIN

  -- variable declarations
    SET
  @id INT(10) ;
SET
  @keywords VARCHAR(255) ;
SELECT
  id_product()
INTO
  @id ; 
   -- Find tags for productID
   @keywords =SELECT GROUP_CONCAT(t.`name`)FROM`ps_tag` t WHERE t.`id_tag` IN(SELECT pt.`id_tag` FROM `ps_product_tag` pt WHERE pt.`id_product=@id)

   -- update record into  table 
   UPDATE ps_product_lang SET 'meta_keywords' = @keywords WHERE 'id_product' = @id

END; 

DELIMITER ;

0 个答案:

没有答案