我有一个mySQL数据库来存储自行车的位置信息。对于'最后位置'的方法,我只想得到自行车的最后一个入口,但是从所有的自行车。获取最新条目组数据
例子:
ID | ## LAT ## | ## LNG ## | #### TIMESTAMP #### | BIKE_ID
----------------------------------------------------------
16 | N47.68526 | E16.59032 | 2015-01-12 14:49:51 | 3
17 | N47.36345 | E16.12096 | 2015-01-12 14:50:27 | 9
18 | N44.12526 | E15.12562 | 2015-01-12 14:51:45 | 1
19 | N47.87654 | E16.54323 | 2015-01-12 14:51:51 | 3
20 | N47.12345 | E16.12341 | 2015-01-12 14:52:27 | 1
21 | N47.12531 | E15.12561 | 2015-01-12 14:52:45 | 9
22 | N44.12531 | E16.12561 | 2015-01-12 14:53:01 | 1
23 | N47.12531 | E15.12561 | 2015-01-12 14:53:18 | 9
...
我想要的输出,如:
ID | ## LAT ## | ## LNG ## | #### TIMESTAMP #### | BIKE_ID
----------------------------------------------------------
19 | N47.87654 | E16.54323 | 2015-01-12 14:51:51 | 3
22 | N44.12531 | E16.12561 | 2015-01-12 14:53:01 | 1
23 | N47.12531 | E15.12561 | 2015-01-12 14:53:18 | 9
检查[此答案](http://stackoverflow.com/questions/27183964/sql-sorting-does-not-follow-group-by-statement-always-uses-primary-key/27184343#27184343), [this one](http://stackoverflow.com/questions/27801243/how-to-select-a-row-with-maximum-value-for-a-column-in-mysql/27801835#27801835),[this一个](http://stackoverflow.com/questions/27036210/sql-select-first-column-and-for-each-row-select-unique-id-and-the-last-date/27036920#27036920)和[this one](http://stackoverflow.com/questions/612231/how-can-i-select-rows-with-maxcolumn-value-distinct-by-another-column-in-sql/27802817#27802817)。 – axiac
我敢打赌,这是关于SO的最常问的MySQL问题。 – axiac
[检索每个组中的最后一条记录]的可能的重复(http://stackoverflow.com/questions/1313120/retrieving-the-last-record-in-each-group) –