开发者

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

开发者 https://www.devze.com 2022-12-15 07:52 出处:网络
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 wo

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

精彩评论

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

关注公众号