I have a MySQL issue
i want to have the result of the next query into a var and use it to update into the trigger i am trying to get the names comma separated
The query returns more then one row
SELECT t.naam
FROM trefwoorden t
INNER JOIN organisaties_has_trefwoorden AS o ON (t.id_trefwoorden = o.id_trefwoorden)
WHERE o.id_organisaties = NEW.id_organisaties;
Here is the trigger
CREATE TRIGGER updCheck_After AFTER
UPDATE ON organisaties_has_trefwoorden
FOR EACH row
UPDATE organisaties o
SET o.trefwoorden_flat =
(
SELECT t.naam
FROM trefwoorden t
INNER JOIN organisaties_has_trefwoorden AS o ON (t.id_trefwoorden = o.id_trefwoorden)
WHERE o.id_organisaties = NEW.id_organisaties;
)
WHERE o.id_organisaties = NEW.id_organisaties
The开发者_运维知识库 question is it possible to select more rows as 1 column comma separated or is there a other solution ?
someone a suggestion ?
UPDATE organisaties o
SET o.trefwoorden_flat =
(
SELECT GROUP_CONCAT(t.naam SEPARATOR ',')
FROM trefwoorden t
INNER JOIN
organisaties_has_trefwoorden AS o
ON t.id_trefwoorden = o.id_trefwoorden
WHERE o.id_organisaties = NEW.id_organisaties
)
WHERE o.id_organisaties = NEW.id_organisaties
精彩评论