First, select last 20 entries. Then sort them in ascending order. You can easily do this in a single query (with subquery):
select * from (
select * from your_table order by id desc limit 20
) tmp order by tmp.id asc
More Related Contents:
- While loop inserts three times
- Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in? [duplicate]
- regarding installation of php in windows
- save user images in MYSQL database by which method? [closed]
- Im trying to create some temporary tables in mysql using php
- How to apply bindValue method in LIMIT clause?
- Best way to INSERT many values in mysqli?
- Importing CSV data using PHP/MySQL
- Convert latin1 characters on a UTF8 table into UTF8
- php/mysql with multiple queries
- Notice: Array to string conversion in
- How to search for slash (\) in MySQL? and why escaping (\) not required for where (=) but for Like is required?
- Find total number of results in mySQL query with offset+limit
- mysql_fetch_array() expects parameter 1 to be resource problem [duplicate]
- PDO multiple queries
- Using strtotime for dates before 1970
- How to efficiently find the closest locations nearby a given location
- Turn database result into array
- How to set up entity (doctrine) for database view in Symfony 2
- Update query with PDO and MySQL
- (mysql, php) How to get auto_increment field value before inserting data?
- Trying to get property of non-object – CodeIgniter
- What is the type this string? a:1:{s:2:”en”;}
- PHP to store images in MySQL or not?
- UTF-8 character encoding battles json_encode() [duplicate]
- How can I pass an array of PDO parameters yet still specify their types?
- MySQL & PHP Parameter 1 as Resource
- MySQL GROUP BY and Fill Empty Rows
- mysql injection damages?
- MYSQL select a piece of a string and order by that piece