Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
in MySQL, if I'm not mistaken, there is no analogue of json_agg, but you can solve this problem, for example, by concatenation, like this (the request was written on the knee as an example of the direction where to move):
SELECT
t1.id,
CONCAT('[{',
GROUP_CONCAT(
(SELECT CONCAT('field1: ', t2.field1, ', field2: ' t2.field2) FROM t2 WHERE t2.id = t1.id)
SEPARATOR ' }, { '
), '}]'
FROM t1 GROUP BY t1.id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question