选择最后5个mysql行

时间:2015-04-06 06:04:16

标签: php mysql

我想获得最后6行,但跳过结果中的最后一行:

SELECT * FROM stats_follow ORDER BY id DESC LIMIT 6

我该怎么做?

2 个答案:

答案 0 :(得分:0)

试试这个:

SELECT *
FROM (SELECT *
      FROM TableName
      ORDER BY FieldName DESC
      LIMIT 5) sub
ORDER BY FieldName ASC

答案 1 :(得分:0)

试试这个:

SELECT * FROM stats_follow ORDER BY id DESC LIMIT 1,6