Re: retrieve last n records

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I need the last n records when, say user_id  = 3.  So it returns all rows where
user_id = 3, then, on top of that I need only the n most recently entered
records.  The problem with the sorting mechanism I have existing is essentially
that those last n rows need to be sorted ASC or DESC by every field.  So
basically, I need to be able to retrieve those last n rows where user_id =
whatever, then be able to sort those last 3 rows ASC or DESC by any field.



Jim Hunter wrote:

>
>
>  I guess I am confused, how does one query effect a query that you have in
> an other part of the page? The two queries are not related. The second thing
> I am confused on is: Do you want the last n records that were added to the
> table or do you want the last n records in a given index?
>
> Jim
>
> -------Original Message-------
>
>
>
> From: drparker
>
> Date: Thursday, March 06, 2003 13:46:58
>
> To: php-db@lists.php.net
>
> Subject:  retrieve last n records
>
>
>
> I need to retrieve the last n records of a table, n will probably be 2
>
> or 3. I know that I can accomplish this by: select * from table order
>
> by field DESC Limit n, but i would prefer not to do this way because it
>
> interferes with my sorting mechanism on the main page. Is there any
>
> other way to do it?
>
>
>
>
>
>
>
>
>
> --
>
> PHP Database Mailing List (http://www.php.net/)
>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> .


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux