开发者

Getting the last 30 rows

开发者 https://www.devze.com 2023-01-31 20:26 出处:网络
How can you get the last 30 rows (i.e. the last 30 rows to be inserted) into a database us开发者_Python百科ing SQL?

How can you get the last 30 rows (i.e. the last 30 rows to be inserted) into a database us开发者_Python百科ing SQL?

SELECT * FROM table LIMIT x,y ?

An example table:

USER: id (auto increment, int, pk), username, email  


SELECT * FROM table ORDER BY id DESC LIMIT 30


you would have to have some key to go with... is there an auto-incrementing column, then order by THAT column descending... Ex:

select * from YourTable order by TheAutoIncrementColumn DESC limit 30

0

精彩评论

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