I asked this question on the MySQL official forum:
A simplified version of my table is like this:
ID Time Thread
1__4:15__44
2__4:30__44
3__5:10__32
4__6:45__12
5__7:33__44
6__9:14__32
What if I want to select only one of each unique thread? And the ones that get selected must be the latest time? So here’s my result:
ID Time Thread
4__6:45__12
5__7:33__44
6__9:14__32
But I got a very complicated answer. Can you explain what is going on?
SELECT t1.ID, t1.Time, t1.Thread
FROM mytable AS t1
LEFT JOIN mytable AS t2 ON t1.Thread = t2.Thread AND t1.Time < t2.Time
WHERE t2.Time IS NULL;