Answer the question
In order to leave comments, you need to log in
How to concatenate the result of a MySQL one-to-many selection?
There is a table with tasks and there is a table with the fields of these tasks (Redmine database).
Now the sample is obtained in the following way:
select
i.subject
,cv.value
,cv1.value
,cv2.value
from
issues i
left join custom_values cv on cv.custom_field_id=23 and cv.customized_id = i.id
left join custom_values cv1 on cv1.custom_field_id=21 and cv1.customized_id = i.id
left join custom_values cv2 on cv2.custom_field_id=24 and cv2.customized_id = i.id
where 1=1
and t.id in (2,3,4,5)
and cv.value = 'Да'
Answer the question
In order to leave comments, you need to log in
I will try to advise pseudo-code:
leave one join
and move part of the condition to WHEREcv.custom_field_id IN (21,23,24)
The query does not look like it could be simplified.
But to increase the speed of sampling, you can add an index on the custom_field + customized_id fields, if it does not already exist.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question