--- Original Message --- From: "Joshua J. Kugler" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sun, 07 Mar 2004 04:57:30 -0900 Subject: Re: Selectinmg most recent dates from multiple table items
> SELECT DISTINCT sensor_id, other_fields FROM table_name > ORDER BY time_stamp_field DESC LIMIT 40 > > > Not sure if that will work, but does it point you in the right > direction? When I use this I end up getting the most recent 40 sensor readings from the same sensor. I'm trying to figure out the proper query to get the most recent sensor reading from each of the 40 sensors. > On Saturday 06 March 2004 07:22 pm, Tim McDonough wrote: > This seems similar to something I'm working on which I haven't > sorted out to my satisfaction yet. > > We have a system that collects and stores data that is time > stamped in a mysql database. There is data from 40 sensors and it > does not arrive at exactly the same time so each sensor reading > and it's time stamp are stored. The table contains a date/time, > the sensor ID, and the value. > > One request is to have a web page that will display each sensor > and it's most recent measurement so the most recent is always > shown. regardless of which sensor it came from. How do I create a > query that will extract the most recent data (latest date) from > the database for each of the sensors and have it sorted it by the > sensor ID? > > This isn't obvious to me from reading the documentation on > queries and I've been searching and reading through messages > without success yet. I suspect a big part of the problem is I'm > fairly new to sql queries and am not exactly sure what terms to > search for. > > Tim -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]