遇到以下查询问题。我有一个设备表,记录区域中的设备,以及venue_id和日期时间戳。我试图从一天,一个月和一年中获得场地中的所有设备,但是当天下午12点之后和第二天中午12点之前才发现设备。我试过这个,这是我最接近的。
SELECT COUNT( DISTINCT (mac) ) AS devices,
EXTRACT( DAY FROM DATE_ADD(date_time, INTERVAL 12 HOURS) ) AS day
FROM detected_devices
WHERE venue_id = 1
AND EXTRACT( MONTH FROM DATE_ADD(date_time, INTERVAL 12 HOURS) ) = 12
GROUP BY day
ORDER BY day ASC
这不起作用,并给我以下错误。
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'FROM detected_devices WHERE client_id = 11 AND venue_id = 1 AND EXTRACT( MONTH F' at line 2