I have a this table:
posts
id | msg | topicId
1 | Hello World| 1
2 | Whats up? | 2
3 | lorem ipsum| 1
4 | new Topic | 3
5 | Dolor sit | 1
6 | some text | 3
7 | response | 2
8 | asdf | 3
I want to get the row with the biggest id
for every topicId
like this:
result
id | msg | topicId
5 | Dolor sit | 1
7 | response | 2
8 | asdf | 3
My problem is I don't have a clue how to query for the result I want. I'm using symfony 2.3 and doctrine, so if you could use the doctrine query builder code for the answer that would be great :)
Any idea to do this efficiently?