It is very database implementation depend...I think... Oracle might take 3
rows and then do a order by DESC...  not exactly what you want.

-----Original Message-----
From: Moritz von Schweinitz [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 06, 2001 12:42 PM
To: 'Tomasi, Chuck'; [EMAIL PROTECTED]
Subject: RE: Select latest entry for a group of records


SELECT * FROM table ORDER BY updated DESC LIMIT 3;

or simply $sth->fetchrow_whatever as you need.

(or didn't i get the question?)

M.

> -----Original Message-----
> From: Tomasi, Chuck [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, December 06, 2001 11:32 AM
> To: [EMAIL PROTECTED]
> Subject: Select latest entry for a group of records
> 
> 
> I've got table to track my backup tapes.  Each time a tape is 
> used, I log a few things about it.  I would like to construct 
> a select statement to show me the last entry for tape has been.
> 
> desc tape;
> Name          Type
> =============================
> ID            number
> Location      number
> Updated       date
> 
> Input data may look something like:
> 
> 1     12      10-Oct-01
> 2     14      10-Oct-01
> 1     12      12-Oct-01
> 4     10      12-Oct-01
> 2     14      14-Oct-01
> 
> In this case, I would only like the tree latest entries:
> 
> 1     12      12-Oct-01
> 4     10      12-Oct-01
> 2     14      14-Oct-01
> 
> --Chuck
> 

Reply via email to