query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stijn Goris

    query

    hi all,

    Simple problem:
    I have a entry with an ID. What is the easiets way to get the row with an ID
    that is left (smaller) and right (higher)

    Example
    ID | filename
    5 test.jpg
    6 low.jpg
    8 nice.jpg
    9 cloud.jpg
    10 rain.jpg
    13 high.jpg

    I have nice.jpd (ID = 8) and want to get the 'right' ID (low.jpg) and the
    'right' ID (cloud.jpg)

    IS there an easy way

    kind regards
    Stijn


  • Andy Hassall

    #2
    Re: query

    On Fri, 05 Mar 2004 13:29:35 GMT, "Stijn Goris" <mepisto@hotmai l.com> wrote:
    [color=blue]
    >Simple problem:
    >I have a entry with an ID. What is the easiets way to get the row with an ID
    >that is left (smaller) and right (higher)
    >
    >Example
    >ID | filename
    >5 test.jpg
    >6 low.jpg
    >8 nice.jpg
    >9 cloud.jpg
    >10 rain.jpg
    >13 high.jpg
    >
    >I have nice.jpd (ID = 8) and want to get the 'right' ID (low.jpg)[/color]

    select max(ID)
    from example
    where ID < 8
    [color=blue]
    >and the 'right' ID (cloud.jpg)[/color]

    select min(ID)
    from example
    where ID > 8

    --
    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
    <http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>

    Comment

    • Stijn Goris

      #3
      Re: query


      "Andy Hassall" <andy@andyh.co. uk> wrote in message
      news:is0h40tp7q o574h1ngip7g5qu 54uohro4r@4ax.c om...[color=blue]
      > On Fri, 05 Mar 2004 13:29:35 GMT, "Stijn Goris" <mepisto@hotmai l.com>[/color]
      wrote:[color=blue]
      >[color=green]
      > >Simple problem:
      > >I have a entry with an ID. What is the easiets way to get the row with an[/color][/color]
      ID[color=blue][color=green]
      > >that is left (smaller) and right (higher)
      > >
      > >Example
      > >ID | filename
      > >5 test.jpg
      > >6 low.jpg
      > >8 nice.jpg
      > >9 cloud.jpg
      > >10 rain.jpg
      > >13 high.jpg
      > >
      > >I have nice.jpd (ID = 8) and want to get the 'right' ID (low.jpg)[/color]
      >
      > select max(ID)
      > from example
      > where ID < 8
      >[color=green]
      > >and the 'right' ID (cloud.jpg)[/color]
      >
      > select min(ID)
      > from example
      > where ID > 8
      >
      > --
      > Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
      > <http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>[/color]

      thanks


      Comment

      Working...