I have a 106 line query to draw in data from all over a relational database and dump into a single table for export. I am having issue with one section of the code, where I want to pull multiple rows (the first 5) into a delimited column for each row in the destination table.
Here is the SQL for that one column, found in the column list of the select query:
I believe that the sub query is returning multiple rows of delimited columns, instead of just the one. I don't know how to pass in key_1 from the main query. I think if I had that last piece that the query would be functioning as desired.
I have spent the last couple days searching for the needed piece in the documentation and in articles, but I have found nothing that deals with this. Any insight would be greatly appreciated.
Here is the SQL for that one column, found in the column list of the select query:
Code:
SUBSTRING_INDEX(
(select group_concat( source_col separator '...' )
from table1
left join table2 using( key_1 )
left join table3 using( key_2 )
where col_3 < 'val'
group by ( key_1 ) ),
'...', 5) AS `col_dest`,
I believe that the sub query is returning multiple rows of delimited columns, instead of just the one. I don't know how to pass in key_1 from the main query. I think if I had that last piece that the query would be functioning as desired.
I have spent the last couple days searching for the needed piece in the documentation and in articles, but I have found nothing that deals with this. Any insight would be greatly appreciated.