Moritz von Schweinitz writes: > SELECT * FROM table ORDER BY updated DESC LIMIT 3; > > or simply $sth->fetchrow_whatever as you need. > > (or didn't i get the question?)
I think it's a little bit more complicated that that. If I understand the question correctly he wants the latest row for each "Location". That's a lot trickier to do in plain SQL. With Sybase I'd probably use a temp table to accumulate the appropriate results and then select all the data from the temp table. Michael > > -----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 > > > -- Michael Peppler - Data Migrations Inc. - http://www.mbay.net/~mpeppler [EMAIL PROTECTED] - [EMAIL PROTECTED] International Sybase User Group - http://www.isug.com
