|
|
 |
Re: FN-FORUM: Mysql syntax help
date posted 1st May 2008 16:02
On Thu, 2008-05-01 at 16:17 +0000, Nigel Rogers wrote:
> Hi, I think this is a simple question:
>
>
> I have a simple query that requests the 3 most recent album entries
> from a mysql database
>
> $maxRows_Albums = 3;
>
>
> which i order by recent first...
>
> $query_Albums = "SELECT * FROM albumlist ORDER BY id DESC";
>
>
Is id always greater for later entries? (You'd get that if you had set
the autoincrement attribute on that field). If so then you'd get what
you want by selecting all but the largest id entry and then limiting
your results to the next three. So something like:
SELECT * FROM albumlist where id < ( select max(id) from albumlist )
order BY id DESC limit 3
(the limit 3 is mysql dialect)
Graham
--
Graham Stark, Virtual Worlds, http://www.virtual-worlds.biz
Phone (+44) 01908 618239 Mobile (+44) 07952633185 Skype graham_k_stark
|
 |
|