Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2006
    Posts
    57

    Unanswered: getting results between 10 and 20

    Here is my query

    Code:
    SELECT ItemName,ItemDesc FROM CATAGORY
    This query returns over 80 results but I only need the results between 10 and 20 how can I modify the query to do that?

  2. #2
    Join Date
    Dec 2005
    Posts
    266
    SELECT ItemName,ItemDesc FROM CATAGORY WHERE ItemDesc between 10 and 20

  3. #3
    Join Date
    Sep 2006
    Posts
    57
    hmmmm...that query seem to return no results. here is an example:


    table:

    Code:
    ItemsID           ItemDesc                  Price            Catagory
    1                    Binoculars                $100             Hunt
    2                    Boots                      $20               Hunt
    3                    Camoflauge              $59               Hunt
    4                    Whistle                    $5                Hunt
    5                    PLastic Bags             $300             Specialty
    6                    Rifle                        $800             Hunt
    7                    Bate                        $.59             Fish
    8                    Salt                         $2.00           Fish

    Take this table for example my query returned all results for catagory "Hunt" but I only want the results that are between 2 and 4.

    The results that are being retured are too much to display in a webpage so I am trying section the information by pages. Page 1, page 2, page 3


    Code:
    SELECT ItemName,ItemDesc FROM CATAGORY WHERE ItemDesc between 10 and 20
    The query above does not return any results. I am puzzled
    Last edited by Luke101; 11-10-06 at 19:24.

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Cast ITEM as an integer. You are doing string comparisons on numeric values.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  5. #5
    Join Date
    Sep 2006
    Posts
    57
    hmmmm...I am not trying to do a string comparison. I am only trying to get data "page by page".

    For example if a certain query returns 1000 rows. Well I want to display row 20 through 30 because the user is on page 3. Anyone have any ideas?
    Last edited by Luke101; 11-10-06 at 20:27.

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    OMG, paging -- it sure didn't sound like that at the beginning of this thread

    see http://rosca.net/writing/articles/serverside_paging.asp
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Dec 2005
    Posts
    266
    I thought ItemDesc was an integer !
    of course it cannot work

    as says r937 you have never said it was for paging

  8. #8
    Join Date
    Sep 2006
    Posts
    57
    hey thanks fellas its working now i appreciate all the responses

    And sorry about the misunderstanding

Posting Permissions

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