i have field ID with records:
1
2
3
.
.
9
10
is there mysql query syntax like select bottom 5 * from table order by id desc
?
8
7
6
5
4
Thanks!
please try running following query.
select column_name from table_name order by id desc limit 5;
SELECT id FROM table ORDER BY id DESC LIMIT 5
see LIMIT
If you like to select entries 10,9,[8,7,6,5,4],.. try (3 start index, 5 row count)
SELECT id FROM table ORDER BY id DESC LIMIT 3,5
Or 1,2,3,[4,5,6,7,8],9,10
SELECT id FROM table ORDER BY id ASC LIMIT 4,5
you can use the LIMIT
keyword in mySQL
Examples:
SELECT * FROM `your_table` LIMIT 0, 10
This will display the first 10 results from the database.
SELECT * FROM `your_table` LIMIT 5, 5
This will show records 6, 7, 8, 9, and 10
SELECT * FROM `your_table` ORDER BY 1 DESC LIMIT 5, 5
This will show records 10, 9, 8, 7 , and 6