我正在尝试创建一个将基于当天的查询。我不知道WHERE中的参数,目前,我使用日期作为字符串。
SELECT`u.firstname AS `user`,COUNT(acc.submit_dt) AS `submitted`
FROM asset_camera_check AS acc JOIN users u ON u.userid = acc.user_id
WHERE(acc.submit_dt = currentdate AND
acc.submit_dt < '2016-3-23 6:00:00'GROUP BY u.userid
最佳答案
您的WHERE
子句需要一个右括号(或者只是去除左括号-您在这里不需要括号)。
除了语法外,如果您想做的是包含“今天”的00:00(含)和06:00(不含)之间的记录,请尝试以下操作:
SELECT
u.firstname AS `user`,
COUNT(acc.submit_dt) AS `submitted`
FROM asset_camera_check AS acc
JOIN users u ON u.userid = acc.user_id
WHERE acc.submit_dt >= current_date
AND acc.submit_dt < current_date + interval 6 hour
GROUP BY u.userid
关于mysql - >日期参数mysql,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36180347/