Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009
    Posts
    23

    Unanswered: retrieve one before the last entry

    Hello
    i understand how to retrieve the last entry with DESC and LIMIT 1

    but is there any way to get the second to last entry ?

    Danny

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    It isn't particularly efficient but if you're comfortable with using DESC and LIMIT then this might work:

    Code:
    select *
    from (  select *
            from table
            order by main_field desc
            limit 2 ) tmp
    order by main_field
    limit 1

  3. #3
    Join Date
    Jul 2009
    Posts
    23

    got it

    some one helped me like that and its working

    Go exactly like DESC and LIMIT 1, but instead of LIMIT 1 do this:

    LIMIT 1,1

    (LIMIT 1 actually is LIMIT 0,1)

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •