我的表描述是
+-------------+-----------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-----------------+------+-----+-------------------+-----------------------------+
| AutoPk | int(4) unsigned | NO | MUL | NULL | |
| sensorName | varchar(20) | NO | | NULL | |
| SensorValue | double(65,2) | NO | | 0.00 | |
| timest | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+-------------+-----------------+------+-----+-------------------+-----------------------------+
Sample data is
+----------+--------------+--------------+---------------------+
| AutoPk8_ | sensorName8_ | SensorVa3_8_ | timest8_ |
+----------+--------------+--------------+---------------------+
| 104 | temperature | 14.22 | 2013-09-20 09:59:35 |
| 104 | humidity | 71.74 | 2013-09-20 09:59:35 |
| 104 | humidity | 71.24 | 2013-09-20 09:56:42 |
| 104 | temperature | 14.36 | 2013-09-20 09:56:41 |
| 104 | temperature | 14.47 | 2013-09-20 09:53:47 |
| 104 | humidity | 71.03 | 2013-09-20 09:53:47 |
| 104 | temperature | 14.74 | 2013-09-20 09:50:54 |
| 104 | humidity | 70.50 | 2013-09-20 09:50:54 |
| 104 | light intensi| 12 | 2013-09-20 09:49:00 |
| 104 | temperature | 15.28 | 2013-09-20 09:48:00 |
| 104 | humidity | 69.60 | 2013-09-20 09:48:00 |
+----------+--------------+--------------+---------------------+
10 rows in set (0.06 sec)
现在我需要一个查询来查找基于 sensorName 的最新记录。这里的最新记录是指最新的时间记录。
对于上面的 i/p 输出应该是
104 | temperature | 14.22 | 2013-09-20 09:59:35
104 | humidity | 71.74 | 2013-09-20 09:59:35
104 | light intensi| 12 | 2013-09-20 09:49:00
请帮我 。提前致谢。