I have table called comments
with following structure:
id | entry_id | date | comment
I also have a table called entries
with following structure:
entry_id | title | date | entry
I just want to show recent comments and entries, to which these comments were added.
Now I'm using this query:
SELECT c.id,
c.date,
c.comment,
e.entry_id,
e.title
FROM entries e
INNER JOIN comments c
ON e.entry_id = c.entry_id
GROUP BY c.date DESC
LIMIT 50
And I output the results so:
#entry_id
1 hour ago:
Some comment
#entry_id
2 hours ago:
Some comment
Comments are ordered by date. What I'm trying to do is simply group comments by same entry_id
, e.g.:
#entry_id
1 hour ago:
Some comment
2 hours ago:
Some comment without repeating the `entry_id`
#other entry_id
5 hours ago:
Some comment
How would I do that? No need to write a code for me, just say how would you do that (in pseudo code, for example). This is comments grouping like on facebook or google+ stream, I hope you understand what I mean.