For example, $x1 = 10, $x2 = 25 then it will work Limit $x1, $x2. But I want to make Limit $x2, $x1 and it doesn't work. I want to get from newest to oldest entry from that list. ORDER BY doesn't work
edited you开发者_运维百科 can close it, I've figured out by myself. I use
ORDER BY a_time DESC LIMIT $x2-$x1
now, so thanks.
To select the first 10 rows...
SELECT * FROM customer ORDER BY id ASC LIMIT 0, 10
To select the last 10 rows....
SELECT * FROM customer ORDER BY id DESC LIMIT 0, 10
This tells the script to start at 0, then count 10 rows. This is the best/most efficient way of doing this.
Just ORDER BY key DESC;
Then get end of the list. $count-$x2
精彩评论