The best way is to do this in SQL using group_concat
:
SELECT t.*, group_concat(td.item) as items
FROM transmittal t LEFT JOIN
transmittal_documents td
ON td.transmittal_id = t.transmittal_id
GROUP BY td.transmittal_id;
I think you mean left join
rather than right join
. The left join
will keep everything in the transmittal
table along with all matches in the other table.