Select UNIQUE return I have a table as following:

id   | vid | data | time
------------------------------------
1    |  4  |  0   | 1333635317
2    |  4  |  1   | 1333635323
3    |  2  |  0   | 1333635336
4    |  4  |  1   | 1333635343
5    |  5  |  0   | 1333635349
6    |  5  |  1   | 1333635350


I want to be just a row (the last row [ID: 4,6]) of the same rows[id:1,2,4,5], how it will output the query?

I mean, as a result of these:

id   | vid | data | time
------------------------------------
3    |  2  |  0   | 1333635336
4    |  4  |  1   | 1333635343
6    |  5  |  1   | 1333635350


What do i do?

i trying it as:

SELECT * from tbale as t1 where vid = 4 GROUP BY vid ORDER BY id DESC


but doesn't work ORDER BY in my query.
Select the MAX(time) grouping by vid and find the corresponding Id.

select t1.id, t1.vid, t1.data, t1.time
from yourTable t1
     join (select vid, max(time) as time
           from yourTable
           group by vid) t2
     on t1.vid = t2.vid
     and t1.time = t2.time;


If you need WHERE or ORDER BY:

select t1.id, t1.vid, t1.data, t1.time
from yourTable t1
     join (select vid, max(time) as time
           from yourTable
           group by vid) t2
     on t1.vid = t2.vid
     and t1.time = t2.time
WHERE t1.SOME_FIELD = SOME_VALUE
ORDER BY t1.SOME_FIELD;