《MYSQL數(shù)據(jù)庫MySQL查詢倒數(shù)第二條記錄實(shí)現(xiàn)方法》要點(diǎn):
本文介紹了MYSQL數(shù)據(jù)庫MySQL查詢倒數(shù)第二條記錄實(shí)現(xiàn)方法,希望對您有用。如果有疑問,可以聯(lián)系我們。
有時(shí)候會用到查詢倒數(shù)第二條記載
MYSQL數(shù)據(jù)庫
代碼如下:
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;?
《MYSQL數(shù)據(jù)庫MySQL查詢倒數(shù)第二條記錄實(shí)現(xiàn)方法》是否對您有啟發(fā),歡迎查看更多與《MYSQL數(shù)據(jù)庫MySQL查詢倒數(shù)第二條記錄實(shí)現(xiàn)方法》相關(guān)教程,學(xué)精學(xué)透。維易PHP學(xué)院為您提供精彩教程。
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/13985.html