利用子查询示例:
SELECT * FROM your_table WHERE id <=
(SELECT id FROM your_table ORDER BY id desc LIMIT ($page-1)*$pagesize )
ORDER BY id desc LIMIT $pagesize
利用连接示例:
SELECT * FROM your_table AS t1
JOIN (SELECT id FROM your_table ORDER BY id desc LIMIT ($page-1)*$pagesize ) AS t2
WHERE t1.id <= t2.id ORDER BY t1.id desc LIMIT $pagesize;
select count(*) 和 select count(1)有什么区别
count(1)就是count(1),这表明是求值。
count(*)变成了count(0),这表明是计算行数的。
时间: 2024-10-24 23:52:32