Re: getting lines from the highest ID in a database?
| From: | Michael Virnstein | Date: | Fri, 05 Apr 2002 11:09:33 +0000 |
| Subject: | Re: getting lines from the highest ID in a database? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-91687@lists.php.net to get a copy of this message | ||
this should do the trick:
SELECT MAX(field) from table
you have to use MAX to get the highest value in field.
Michael
"Jason Wong" <php-general@gremlins.com.hk> schrieb im Newsbeitrag
news:php.general-91679@news.php.net...
> On Friday 05 April 2002 18:27, Hawk wrote:
> > Lets say I have a guestbook, and that I only want to show the last entry
on
> > my first page
> > I cant figure out a good way to do it..
> > haven't managed to find a mysql command that can do it either, but maybe
> > there are? :)
>
> The only reliable way to do it is to have a field in your guestbook table
> which records the time that the entry was made. Then you can:
>
>
> SELECT * FROM guestbook ORDER BY time_entered LIMIT 1
>
> I have set follow-up to php-db@lists.php.net where this belongs.
>
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
>
> /*
> If there is any realistic deterrent to marriage, it's the fact that you
> can't afford divorce.
> -- Jack Nicholson
> */