I have a problem with MySQL
I want to get the result of the following query in var and use it to update in a trigger. I am trying to get comma separated names
The query returns more than 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, can I select more rows in the form of 1 column, separated by a comma, or is there another solution?
Does anyone suggest?
Marco source
share