1

I'm trying to create insert and update triggers with SELECT GROUP_CONCAT request on one of the fields;

This select query perfectly works, when I trying it in console, but trigger saves only first line of GROUP_CONCAT and ignores concatination at all... How can I solve this?

UPD trigger code:

CREATE TRIGGER `insert` AFTER INSERT ON `adp_films`
FOR EACH ROW
INSERT INTO adp_films_search (`id`, `code_title`, `title`, `channel`, `cycle`, `annotations`, `author`, `rights`, `tags`)
VALUES(
    NEW.`id`,
    NEW.`code_title`,
    NEW.`title`,
    (SELECT GROUP_CONCAT(distinct(`adp_channels`.`channel`)) as channel FROM `adp_cycles` LEFT JOIN `adp_channels` on `adp_cycles`.`channel` = `adp_channels`.`id` WHERE `adp_cycles`.`id` in (NEW.cycle)),
    (SELECT group_concat(`cycle`) as cycle FROM `adp_cycles` WHERE id in (NEW.cycle)),
    NEW.`annotations`,
    (SELECT `author` FROM `adp_authors` WHERE `adp_authors`.id = NEW.`author`),
    (SELECT concat(`territory`, " ", `license`, " ", `sold_to`) FROM `adp_rights` WHERE `adp_rights`.`id` in (NEW.`rights`)),
    (SELECT GROUP_CONCAT(`tag`) FROM `adp_tags` WHERE `adp_tags`.`id` in (NEW.`tags`))
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.