I thought about that, but I'd like to avoid the "sort".  That could get
expensive as the list grows.  I'm still willing to do that if there is no
other way, but part of this is just academic.  I would think there should be
a way of retrieving the most recent entry.
  I've also thought of creating another table that contains only the most
recent event, replacing each as another is received.  But this also seems
like a hack. 
  I can't be the first person to have this problem, so I'm curious to know
how others have solved it.

dave

-----Original Message-----
From: District Webmaster [mailto:[EMAIL PROTECTED]
Sent: Monday, October 20, 2003 11:30 AM
To: [EMAIL PROTECTED]
Subject: Re: [uug] SQL help (most recent)


Perhaps you can create a date field with the default value being
Now()-- then sort by said field.

see also:
http://www.mysql.com/doc/en/Date_and_time_functions.html

Dave

>>> [EMAIL PROTECTED] 10/20/03 12:09 PM >>>
  I'm creating a simple mySQL database that is being populated by a perl
script.  Each entry will corresponds to an event that is happening on
another machine.  I'm looking for an SQL query that will return the most
recent entry and I have no way of knowing when that might have been.  It
may
have been two hours ago, or two weeks.  
  The only way I can think of is to ask for the list to be sorted and
take
the first row, but this seems wrong in every way, especially once the
list
starts to grow.
  Any ideas?

dave  

____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list


____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to