to select range of id from table

Discussion in 'MySQL' started by kalaid, Jul 21, 2007.

  1. kalaid

    kalaid New Member

    Joined:
    Jul 21, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    how do you choose a range of ID from a db?

    I used query to select record matched with particular id
    $data = mysql_query("SELECT * FROM table_name WHERE (id=2)")

    I tried like above query to select record with id's 2 through 9
    $data = mysql_query("SELECT * FROM table_name WHERE (1<id<9)")

    it didnt work. Help me
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Use the between keyword.
     
  3. Ami Desai

    Ami Desai Member

    Joined:
    Jan 5, 2017
    Messages:
    42
    Likes Received:
    17
    Trophy Points:
    8
    Location:
    Ahmedabad
    Home Page:
    http://www.ifourtechnolab.com/
    Hi,

    You can use following query

    Thanks
     
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice