我需要做的是(使用 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/