Reputation: 13
Only 5 title; that is my table :
ID Title Time
1 DA-UB 2017-05-14 15:02:03
2 UB-SA 2017-05-14 15:03:03
3 ER-UB 2017-05-14 15:04:03
4 DA-UB 2017-05-14 15:05:03
5 UB-sa 2017-05-14 15:06:03
6 ER-UB 2017-05-14 15:07:03
7 OR-SA 2017-05-14 15:10:03
8 ER-DA 2017-05-14 15:11:03
I want see this(last added 5 row)
4 DA-UB 2017-05-14 15:05:03
5 UB-sa 2017-05-14 15:06:03
6 ER-UB 2017-05-14 15:07:03
7 OR-SA 2017-05-14 15:10:03
8 ER-DA 2017-05-14 15:11:03
Upvotes: 0
Views: 43
Reputation: 39477
Use LIMIT
:
select *
from your_table
order by time desc
limit 5
As per latest update in the comments below, you can use a limited correlated query to get the latest row per title and then limit the result to 5 rows.
select *
from your_table t1
where id = (
select id
from your_table t2
where t1.title = t2.title
order by time desc
limit 1
)
order by time desc
limit 5;
Upvotes: 1