selecting items that come after a specific value

后端 未结 2 1757
臣服心动
臣服心动 2021-01-28 19:00

Say this is my sql:

  SELECT title,
         author,
         ISBN 
    FROM bs_books 
ORDER BY ISBN 
   LIMIT 3

It just selects everything fr

2条回答
  •  天涯浪人
    2021-01-28 19:17

    Find the ISBN for the title you want following-ISBNs for, then simply:

    SELECT title, author, ISBN
    FROM bs_books
    WHERE ISBN>'978-3-16-148410-0' -- or whatever ISBN
    ORDER BY ISBN
    LIMIT 3
    

    If you want to select it from just the title in one go, you could use a self-join:

    SELECT b1.title, b1.author, b1.ISBN
    FROM bs_books AS b0
    JOIN bs_books AS b1 ON b1.ISBN>b0.ISDN
    WHERE b0.title='Title for which to get following ISBNs'
    ORDER BY b1.ISBN
    LIMIT 3
    

提交回复
热议问题