MySQL Query Between 2 ID values.

Discussion in 'PHP' started by cyclotron, Aug 13, 2010.

  1. #1
    Say I have the following query:

    	$select = mysql_query("SELECT * FROM `quotes` ORDER BY `id` DESC LIMIT 32");
    PHP:

    How could I make it so

    a) there's no limit
    b) it echos the values between and including 200 and 300.

    So for id 200, 201, 202 ... 300

    i want it to echo them.
     
    cyclotron, Aug 13, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    $select = mysql_query("SELECT id FROM `quotes` ORDER BY `id` DESC LIMIT 199, 100");
    while($row = mysql_fetch_assoc($select)) {
    echo $row['id'].'<br>';
    }
    PHP:
     
    danx10, Aug 13, 2010 IP
  3. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #3
    Because of
    $select = mysql_query("SELECT * FROM `quotes` WHERE id BETWEEN 200 AND 300 ORDER BY id ASC");
    PHP:
    and continue with Danx10's code to echo it.
    :)
     
    koko5, Aug 13, 2010 IP