Ajay_Kumar
Ajay_Kumar

Reputation: 1387

How to get 2 maximum id from table in mysql

I have many records in my table.I want to fetch 2 records which should have maximum or second last maximum id value .How will i do this in mysql?

Upvotes: 1

Views: 126

Answers (1)

joostdevries
joostdevries

Reputation: 930

SELECT FROM [table] WHERE [condition] ORDER BY `id` DESC LIMIT 2

Upvotes: 5

Related Questions