> Or, you could do two steps
>
> 1) retrieve the last inserted ID, with mysql_last_inserted_ID (or
> something like that).
>
> 2) then, all records with id(s) greater then the_last_id_number minus
> five.
>
> something like
>
> $most_recent = select mysql_last_id();
>
> select * from TA
t;
> Jeff
>
> > -Original Message-
> > From: Justin French [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, August 04, 2001 6:09 AM
> > To: [EMAIL PROTECTED]
> > Cc: php
> > Subject: Re: [PHP] most recent 5 rows
> >
> >
> > Jeff Lewis wrote:
>
Jeff Lewis wrote:
> $sql = "SELECT * FROM news ORDER BY id DESC LIMIT 5";
many many many thanks for your (very quick) help!!
Justin French
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact
ilto:[EMAIL PROTECTED]]
> Sent: Saturday, August 04, 2001 7:06 AM
> To: [EMAIL PROTECTED]
> Cc: php
> Subject: RE: [PHP] most recent 5 rows
>
>
> It will give you the 5 HIGHEST values in your auto incremented
> field. If it
> was returneding the first 5, or
IL PROTECTED]
> Cc: php
> Subject: Re: [PHP] most recent 5 rows
>
>
> Jeff Lewis wrote:
>
> > Try this SQL Justin:
> >
> > $sql = "SELECT * FROM news DESC LIMIT 5";
>
>
> Hrm,
>
> Won't that retrieve the FIRST 5 rows, not the LAST
Jeff Lewis wrote:
> Try this SQL Justin:
>
> $sql = "SELECT * FROM news DESC LIMIT 5";
Hrm,
Won't that retrieve the FIRST 5 rows, not the LAST 5?
Justin French
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMA
Try this SQL Justin:
$sql = "SELECT * FROM news DESC LIMIT 5";
Jeff
> -Original Message-
> From: Justin French [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, August 04, 2001 5:52 AM
> To: php
> Subject: [PHP] most recent 5 rows
>
>
> Hi all,
>
Hi all,
I have a table with the column "id", which is a unique number,
auto-incremented, so the highest "id" is the most recent.
I wish to retrieve the last five rows from the table (there
will be hundreds of rows) and print some columns to the screen.
I have this table:
id,heading,text,use
8 matches
Mail list logo