Re: mysq: get the latest row of a table
| From: | Teodor Cimpoesu | Date: | Sat, 24 Jun 2000 15:04:19 +0000 |
| Subject: | Re: mysq: get the latest row of a table | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-2914@lists.php.net to get a copy of this message | ||
Hi Peter!
On Sat, 24 Jun 2000, Peter Van Dijck wrote:
> Hi,
> I've been thinking about this on and off now for a while, is there a fast
> way to just get the latest row of a table? Looping through all just seems
> like such a waste of time, I'm sure there must be a better way!
> Thanks for any hints you can give,
> Peter
Well, define `latest'.
if you can apply a max() or order that field you can ask for the max field,
e.g.
SELECT MAX(some_attr) FROM some_tbl;
or
SELECT * FROM some_tbl ORDER BY some_attr DESC LIMIT 1;
but that would mean MySQL knows how to order your field (some_attr)
-- teodor