开发者

Retrieve last inserted 10 rows in table

开发者 https://www.devze.com 2023-01-05 16:01 出处:网络
How can I retrieve the last 10 rows inserted 开发者_开发问答into a table?select * from tableName ORDER BY `created_at` DESC LIMIT 10

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

精彩评论

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