选择在特定值之后的项目 [英] selecting items that come after a specific value

查看:49
本文介绍了选择在特定值之后的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说这是我的sql:

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

它只是从某个表中选择所有内容(标题,作者等).

It just selects everything from a certain table (title, author, etc..).

说,我想选择某个标题之后的所有项目,而不是按字母顺序或其他方式,而只是选择该特定元素之后的记录.我将如何处理?

Say I would like to select all the items that come after a certain title, not alphabetically or something but just the records after the certain element. How would I approach this?

推荐答案

找到您要关注的书名(ISBN)的ISBN,然后简单地:

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

这篇关于选择在特定值之后的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆