Reputation: 73
I have 2 tables.
Table 1
Table 2 has comments for the table 1, where the FK is the ID_tb1
:
I'm trying to get a query in order to get all the comments to show as 1 table. If there is no comment in table 2 then there should be no comment but the data from table 1 should still be shown.
Here is an example of how the result should be
Upvotes: 1
Views: 49
Reputation: 28874
Try the following:
Select t1.id, t1.letter
Group_concat(concat(t2.datetime, ' ', t2.comments)) as Comment
From table1 AS t1
LEFT JOIN table2 AS t2 ON t2.id = t1.id
GROUP BY t1.id, t1.letter
Upvotes: 1