0

I have a table

tablea

id   value
__   _____
1     a
2     b
3     c
4     d
5     e

i want to fetch only latest entry in table (i.e) last value =>id,value as 5,e

could you please tell me query for this.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
programmer 05
  • 74
  • 1
  • 11

3 Answers3

1

Use order by and limit:

select t.*
from t
order by id desc
limit 1;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
1

use following select query

SELECT * FROM tablea where ID IN (SELECT MAX(ID) FROM tablea);
Mahesh Madushanka
  • 2,902
  • 2
  • 14
  • 28
1
Select id, value
  from tablea
order by id desc
limit 1
vercelli
  • 4,717
  • 2
  • 13
  • 15