Re: SELECT * help needed.



Simon wrote:

If I have a lot of articles, all with a unique IDs.
First I would like to search for that ID, I could do
SELECT * from ARTICLE where ID = xx
But I also want to display the 5 articles before and after that article.
SELECT * from ARTICLE where ID > xx LIMIT 0, 10
and
SELECT * from ARTICLE where ID < xx LIMIT 0, 10
(I choose a limit of 10 in case the ID is one of the first one or one of the last one, that way I will always have at least 10 articles).
Is it possible to do the above in one single query? Should I even bother doing that? does it make the whole operation faster to do it that way?

SELECT * FROM article WHERE ( x-5 < id and id < x+5 )

  Or pick borders as you like.

  /m
.



Relevant Pages

  • Re: -- Asshole
    ... display preventing me from seeing information about OTHER threads. ... on my lawn, but I can at least organize it so it's not an eyesore. ... whatever it has been messing up, but don't bother to explain!) ... mathematicians have no clue about how things work out in the real world. ...
    (sci.math)
  • Re: Coordinating multiple JTextField updates across panels
    ... no user will ever enter data in 500 textboxes, so there's seems little real need for actually placing as many of them on the screen, in favor of more lightweight components for display. ... The refresh never really bothered me but I can see where it might bother somebody. ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (comp.lang.java.gui)
  • Re: Death To Sub-Sub-Sub-Directories!
    ... Excellent debating skills you put on display there, Lew! ... bother with a detailed counterargument against whatever specific things ...
    (comp.lang.java.programmer)
  • Re: Death To Sub-Sub-Sub-Directories!
    ... Excellent debating skills you put on display there, Lew! ... bother with a detailed counterargument against whatever specific things ...
    (comp.lang.java.programmer)
  • Re: hp50g: Interesting new look
    ... Greg M. wrote: ... The "display screen" ... There is a small particle of dust sitting behind the display cover. ... doesn't bother me, it does bother me that it's permanently there. ...
    (comp.sys.hp48)