以下查询有问题。我有一个设备表,它记录在一个区域中发现的设备,以及一个场地 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