开发者

Getting the last 30 rows

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜