2014-03-03 61 views
0

在我的項目中,我想要選擇退出選項或存款選項的用戶的詳細信息。我怎樣才能做到這一點?在我的MySQL表中選擇倒數第二位

SELECT * 
    FROM `amount_flow` 
    ORDER BY id DESC 
    LIMIT 1 
    WHERE detail = 'withdraw' 

Edit Delete 25 admin 03/03/14 12000 withdraw 3500 
Edit Delete 27 hi234 03/03/14 234  withdraw 3266 
Edit Delete 29 hifft 03/03/14 213  withdraw 3053 <- 
Edit Delete 57 hisat 03/03/14 130     2800 
+1

可以請寫明本例中的列? – krishna

回答

1

變化

SELECT * 
    FROM `amount_flow` 
    ORDER BY id DESC 
    LIMIT 1 
    WHERE detail = 'withdraw' 

SELECT * 
    FROM `amount_flow` 
    WHERE detail = 'withdraw' or detail = 'deposit' 
ORDER BY id ASC LIMIT 1 
+0

謝謝..其作品 – Smoke

+0

不要忘記接受答案。 – krishna

+0

是的兄弟,我很感激 – Smoke