tags:

views:

64

answers:

3

I have a table with several records. There is an id field. I would like to select the record with the most recent id (i.e. the ighest id).

Any ideas?

+1  A: 

User order by with desc order:

select * from t
order by id desc
limit 1
Andrew Bezzub
You forgot that OP said wanted "the" record with highest id -- should have used limit.
MJB
+3  A: 
SELECT * 
FROM table_name
ORDER BY id DESC
LIMIT 1
codaddict
A: 
SELECT   *
FROM     table
ORDER BY id DESC
LIMIT    0, 1
Yassin
`LIMIT 1, 1` is equal to `OFFSET 1 LIMIT 1` therefore penultimate record will be returned.
Crozin
query corrected
Yassin