> 日期参数 mysql
> date arguments mysql
我正在尝试创建一个基于当天提取的查询。我不知道 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
子句需要一个右括号(或者去掉左括号 - 这里不需要括号)。
撇开语法不谈,如果您要尝试为 "today" 包含 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
我正在尝试创建一个基于当天提取的查询。我不知道 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
子句需要一个右括号(或者去掉左括号 - 这里不需要括号)。
撇开语法不谈,如果您要尝试为 "today" 包含 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