# \[MySQL\] Select Unique Entries

**URL:** <https://forum.kirupa.com/t/mysql-select-unique-entries/192451>\
**Category:** programming\
**Created:** [June 28, 2006, 5:55pm UTC](https://forum.kirupa.com/t/mysql-select-unique-entries/192451 "2006-06-28T17:55:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NeoDreamer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@NeoDreamer](https://forum.kirupa.com/u/NeoDreamer)\
**Post date:** [June 28, 2006, 5:55pm UTC](https://forum.kirupa.com/t/mysql-select-unique-entries/192451/1 "2006-06-28T17:55:51Z")

</div>

**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;
