Re: Finding the highest number in a column?

From: Date: Thu, 28 Oct 2004 03:48:18 +0000
Subject: Re: Finding the highest number in a column?
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-37059@lists.php.net to get a copy of this message
On Wed, 2004-10-27 at 20:46 -0700, Robby Russell wrote: > On Wed, 2004-10-27 at 23:33 -0400, Chris Payne wrote: > > Hi there everyone, > > > > > > > > I am working with a very complex system where not all numbers are assigned > > 1, 2, 3 …… etc …… so there could be a row with the number 1 and then the > > next row could be 40 and so on …… > > > > > > > > Is there a way with PHP and MySQL to find out what the highest number is in > > a particular column easily when the numbers are auto-incremented so aren’t > > necessarily one after the other? > > SELECT * FROM table ORDER BY colname DESC LIMIT 1; > > ? > oops, you're looking for the max() now the whole row. MAX() should work for you.. -Robby -- /*************************************** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | robby@planetargon.com * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting & Development * --- Now supporting PHP5 and PHP4 --- ****************************************/

Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
« previous php.db (#37059) next »