"SELECT raw.id,raw.m_id ,latest.`gps-1`, latest.`gps-2`, raw.pm1,raw.pm2_5,raw.pm10, raw.tem, raw.wet, raw.voc, latest.date, latest.time
FROM
(
SELECT `gps-1`, `gps-2`, CONCAT(`gps-1`, ',', `gps-2`) AS latlng, MAX(CONCAT(`date`, ' ', `time`)) AS date_time,
TRIM(SUBSTRING_INDEX(MAX(CONCAT(`date`, ' ', `time`)) ,' ', 1)) AS 'date',
TRIM(SUBSTRING_INDEX(MAX(CONCAT(`date`, ' ', `time`)) ,' ', -1)) AS 'time'
FROM `air`
GROUP BY CONCAT(`gps-1`, ',', `gps-2`)
) AS latest
INNER JOIN
(
SELECT *, CONCAT(`gps-1`, ',', `gps-2`) AS latlng, CONCAT(`date`, ' ', `time`) AS date_time
FROM `air`
) AS raw
ON raw.latlng = latest.latlng
AND raw.date_time = latest.date_time where latest.date=".$_POST['Date']." ;
");
這是目前 抓經緯度一樣 但時間是最新資料
但最後一行不知道哪裡有錯AND raw.date_time = latest.date_time where latest.date=".$_POST['Date']." ;
我想要的結果是可以加上 篩選出例如2016-7-20的資料
希望大大可以幫忙 感恩