Re: Get next data set

From: Date: Sat, 13 Nov 2004 10:41:30 +0000
Subject: Re: Get next data set
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-37253@lists.php.net to get a copy of this message
Merlin wrote:
Hi there, I am trying to figure out how to write a sql statement for mysql with php that returns the next possible data set. For example I do have the ID number of a current data set, now I would like to retrieve the next data set with the next higher ID number. Sometimes there are deleted Ids, thats why one cant just increment the data ID. Here is how I tried it:
    $stmt ="                   SELECT
            g.place
        FROM
            $T33 g
        WHERE
            g.ID < $prev[id]
        LIMIT  1
    ";   
That unfortunatelly returns the very first row in the table. Any ideas how to solve that? Thanx for any help, Merlin
got it :-) ORDER BY ID desc LIMIT 1

« previous php.db (#37253) next »