Re: database selection

From: Date: Mon, 17 Feb 2003 13:20:05 +0000
Subject: Re: database selection
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-135827@lists.php.net to get a copy of this message
One more question about this: If I wanted to select the last row, would I use this code? $query = "SELECT * FROM polls ORDER BY pollID DESC LIMIT 0,1"; "Hans Prins" <HPrins@xgn.nu> schreef in bericht news:20030216135727.52586.qmail@pb1.pair.com... > thank you, > > that did the trick :) > > "Thomas Seifert" <thomas.seifert@myphorum.de> schreef in bericht > news:20030216141748.6aa1753d.thomas.seifert@myphorum.de... > > On Sun, 16 Feb 2003 12:51:58 +0100 HPrins@xgn.nu (Hans Prins) wrote: > > > > > Hello, > > > > > > Im trying to select only one row in a mysql database (in this case a > poll > > > with the smallest pollID)........... > > > Each row has a field called "pollID" which is the primary key and is > auto > > > incremented when a new row is inserted. > > > > > > I could possible do the following but I think its a bit extensive: > > > > > > $query = "SELECT * FROM polls ORDER BY pollID ASC"; > > > $result = mysql_query($query); > > > for ($count = 0; $count < 1 $count++) { > > > $data = mysql_fetch_array($result); > > > $pollID = $data['pollID']; > > > } > > > $query = "SELECT * FROM polls WHERE pollID = $pollID"; > > > > > > Does anyone now a solution for this that requires less code? > > > > > > Thx > > > > > > > > > > $query = "SELECT * FROM polls ORDER BY pollID ASC LIMIT 1"; > > > > > > Thats the only row. > > > > > > > > Regards, > > -- > > Thomas Seifert > > > > mailto:thomas.seifert@myphorum.de > > http://www.MyPhorum.de > >

« previous php.general (#135827) next »