Re: last 10
| From: | Hugh Bothwell | Date: | Sun, 19 May 2002 14:41:26 +0000 |
| Subject: | Re: last 10 | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-19260@lists.php.net to get a copy of this message | ||
"Crosswalkcentral" <webmaster@crosswalkcentral.net> wrote in message
news:20020519031609.89174.qmail@pb1.pair.com...
> How can i obtain the last 10 entries that are in mydatabase that have a
> certain colum set to 1?
SQL does not guarantee to return your records
in any specific order unless you use an ORDER
BY clause.
I would suggest reversing the ORDER BY and
using LIMIT to take the *first* ten records, ie
SELECT *
FROM mytable
WHERE mycolumn=1
ORDER BY mydate DESC
LIMIT 10