开发者

Retrieve last inserted 10 rows in table

How can I retrieve the last 10 rows inserted 开发者_开发问答into a table?


select * from tableName ORDER BY `created_at` DESC LIMIT 10


Hi you can use the below query, please ensure about the primary-key field

select * from tbl ORDER BY 'ID' DESC LIMIT 10


There are two solutions for MySql:

  1. check the rowcount of your table and use limit

    select count(*) from tableName;
    select * from tableName limit rowcount-10,rowcount;
    
  2. PhpMyAdmin displays the results using pagination. You can go to last pages to see last inserted records.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜