• How to get next/previous record in MySQL?

    Answered

    How to get next/previous record in MySQL?

    Bronze Member Asked on June 1, 2017 in MYSQL.
    Add Comment
  • 3 Answer(s)
    Best answer
    
    SELECT * FROM " . DB_PREFIX . "nv_month_seller_payment_records WHERE id < '6'  ORDER BY id DESC LIMIT 1
    
    
    Bronze Member Answered on June 1, 2017.
    Add Comment

     

    next:
    select * from foo where id = (select min(id) from foo where id > 4)
    previous:
    select * from foo where id = (select max(id) from foo where id < 4)
    

     

    Bronze Member Answered on June 1, 2017.
    Add Comment

    next:

    select * from foo where id = (select min(id) from foo where id > 4)

    previous:

    select * from foo where id = (select max(id) from foo where id < 4)
    
    
    Default Answered on March 29, 2018.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.