WhiteHawk
WhiteHawk

Reputation: 89

Selecting the second last digit in my table of MySQL

In my project, I want the detail of a user who selects the withdraw option or deposit option. How can I do that?

 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

Upvotes: 0

Views: 92

Answers (1)

krishna
krishna

Reputation: 4099

change

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

to

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

Upvotes: 1

Related Questions