Re: Slecting data

From: Date: Wed, 11 Oct 2000 03:33:18 +0000
Subject: Re: Slecting data
Groups: php.general 
Request: Send a blank email to php-general+get-19484@lists.php.net to get a copy of this message
In reply to Brian Doing that would be a db overhead ... use : $query = mysql_query("SELECT max(id) FROM table..."); or $query = mysql_query("SELECT count(id) as pl_sqlvar FROM table .."); if u use the above and mysql_fetch_array ... then $results = mysql_fetch_array($query); $highest_id = $results[pl_sqlvar]; this is simple PL programming.... I haven't tested the first one is the reason why I've given a 2nd method though the 1st one should be faster.. --- Website4S@aol.com wrote: > Hi, > > I`m new to this list and fairly new to PHP, just > wondering if anyone can help > me with this problem. > > I`m trying to select data from a table which I can > normally do no probs, but > this time I`m having to display the last entry using > the Where statement but > I`m not sure what to write after this to make sure > it picks up the highest > number. I`m using the following: > > $sql = "SELECT * FROM UKGSSegaNews WHERE ID='????'"; > > I have ID setup in the database table as Primary Key > and auto incrementing so > I always need to pick up the highest numbered > record. Can anyone help me with > this snippet of code?? > > Ade > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: > php-general-unsubscribe@lists.php.net > For additional commands, e-mail: > php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > ===== To Find Out More About Me : http://mukul.tsx.org/ __________________________________________________ Do You Yahoo!? Get Yahoo! Mail - Free email you can access from anywhere! http://mail.yahoo.com/

« previous php.general (#19484) next »