网络编程
位置:首页>> 网络编程>> 数据库>> MySQL查询倒数第二条记录实现方法

MySQL查询倒数第二条记录实现方法

作者:junjie  发布时间:2024-01-26 07:15:50 

标签:MySQL,查询,倒数,第二条

有时候会用到查询倒数第二条记录


last=HolderChangeHistory.find_by_sql
(["               SELECT * FROM holder_change_histories
                  where treasure_id = ?
                  order by id desc  
                  limit   1,1  ",
                  @hch.treasure_id])


select   *    
              from   tablename   a     
              where   ( 
                  select   count(*)    
                       from   tablename   b    
                       where   a.id<b.id)=1 


select   *    
                from   tb1    
                order   by   tb1.id   desc    
                limit   1,1; 

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com