what if we need the last 5 records? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what if we need the last 5 records?

18th Aug 2016, 6:49 PM
bismanjit singh
bismanjit singh - avatar
3 Answers
+ 3
Select * from table_name order by id desc limit 5;
19th Aug 2016, 1:38 PM
Rajkumar
+ 1
ORDER BY id DESC LIMIT 5
18th Aug 2016, 7:34 PM
Jakub Nowacki
Jakub Nowacki - avatar
+ 1
otherwise if you are using sql server you can write SELECT TOP(5), Remember to use order by to sort the rows from the newest to the last
18th Aug 2016, 10:31 PM
Matteo Convertino
Matteo Convertino - avatar