Admittedly I haven't been using much database code lately and something that I think I would have been able to handle on my own before, has me stumped today.
What I need are the 10 latest records, differentiated by a UNIX timestamp column (t1.posterTime).
This is the code as I thought it should be. I get correct results when I remove the GROUP BY but then get dupe rows. What I need are all distinct rows and then order them by the latest UNIX stamp. Easy I know, but I'm stuck. Should I be using a self join for this?
SELECT t1.ID_TOPIC, t1.subject
FROM messages AS t1
GROUP BY t1.ID_TOPIC
Notice that the first column has 3 dupes (117). The far right column is the UNIX stamp. What I need is the max() timestamp column of any duplicated row. This sample data was ran without the GROUP BY clause. If I use the GROUP BY clause the timestamp order is not correct.
It doesn't work. I had that exact same code but it is not giving me the MAX() timestamp
Afraid I don't have your tables to actually try the SQL and I only have your rough description to work with so that was the best I could offer. Things seem a bit better defined now and I assume Rudy's code works so all's well that ends well.