Re: Finding the highest number in a column?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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; 

?

assuming all your column values are unique... 

-Robby

-- 
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | robby@xxxxxxxxxxxxxxx
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now supporting PHP5 and PHP4 ---
****************************************/

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux