Re: Right syntax for max value??

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

 



I would do $getnewstitle = "SELECT newstitle FROM `news` ORDER BY news_id 
DESC LIMIT 1";
 This sorts the records by news_id and the limit 1 only returns the first 
record.

On 6/14/05, twistednetadmin <twistednetadmin@xxxxxxxxx> wrote: 
> 
> I am making a table at my homepage that automatically collects the
> latest news from mysql db.
> I have got it to work at my own server at home, but not at
> www.torewestre.com <http://www.torewestre.com> (my remote site)
> 
> Local settings:(WinXP Pro) Apache 2.0.54, PHP 5.0.4 and MySQL 4.1.11
> 
> Remote settings:(Unix) Apache 1.3.27, PHP 4.3.4 and MySQL 3.23.54
> 
> This is the query that works on localhost:
> 
> 
> $getnewstitle = "SELECT newstitle FROM `news` WHERE news_id = ( SELECT
> max( news_id ) FROM news ) ";
> 
> What it does:
> 
> collects the newstitle from the field where PRIMARY key(news_id) is
> the highest auto_increment number.
> 
> This works just as excpected on localhost but not on remote.
> 
> Does anybody know the right syntax?
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux