php - 选择除第一行以外的最新 10 行

标签 php mysql mysqli

我需要做的是(使用 PHP)从表中选择除第一行(具有最高 ID)之外的最新 10 行。这是怎么做到的?

最佳答案

尝试这样的事情:

SELECT * FROM `table`
ORDER BY `id`  DESC
LIMIT 1,10

http://dev.mysql.com/doc/refman/5.0/en/select.html

The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).

With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):

关于php - 选择除第一行以外的最新 10 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18518529/

相关文章:

php - HORDE Imap PHP 客户端 - 如何获取消息

c++ - sql::InvalidArgumentException MySql C++

mysql - 根据 Hive 中另一个表中的时间戳在表中查找记录

php - 从 SQL 数据库中排序类别列表中的一组子类别

php - 循环检查表中是否存在并生成随机字符串

php - MySQL 过程将空结果返回给 PHP

php - 选择并减少 mysql 查询的字段值

php - 使用php将数据输入mysql数据库

php - Codeception,使用 pageObject 设计模式和小 cucumber 编写验收测试

MySQL 查询在使用双左外连接时用字符串替换空值