简体   繁体   English

表mysql的第二行的第二行

[英]second last row of a table mysql

我在MySQL数据库中玩,只想查看表中倒数第二个但没有得到任何行的查询,下面给出了查询的问题。我的查询有什么问题

SELECT * FROM table WHERE id='(LAST_INSERT_ID()-1)'

LAST_INSERT_ID()-1 has no guarantee of pointing at an actual record. LAST_INSERT_ID()-1无法保证指向实际记录。 Try: 尝试:

SELECT * FROM table ORDER BY id DESC LIMIT 1,1

Ideally you should be using something other than id to determine the age of a record, preferably a timestamp. 理想情况下,您应该使用除id之外的其他内容来确定记录的年龄,最好是时间戳。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM