开发者

Mysql. Limit $x1, $x2. Is it possible to do Limit $x2, $x1?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜