SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    query by intervals

    Is there a command for me to query my database in intervals?

    For example
    query id = 0, 2, 4, 6, 8....

    sec query
    query id = 1, 3, 5, 7...

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    if you want to do it based solely on the id column, yes. but if you have a gap, this will not give you a balanced set of results. for example, imagine the set of id's as follows: 1, 2, 3, 4, 5, 7, 8, 10, 11, 12. (notice 6 and 9 are missing)

    queries in intervals of three would be
    Code:
    select *
      from theTable
     where id div 3 = 1;
    
    results: 1, 4, 7, 10
    
    select *
      from theTable
     where id div 3 = 2;
    
    results: 2, 5, 8, 11
    
    select *
      from theTable
     where id div 3 = 3;
    
    results: 3, 12
    if you want an interval based on the returned rows, that's much more difficult.

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that is what I am looking for, calling out the rows in interval of odds then even. reason why I used id column is because it is easy to call them out by that.

  4. #4
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    um... ok. so does my solution work for you?


Bookmarks

Posting Permissions

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