我正在尝试使用看起来像这样的SQL查询:
'SELECT day(created), hour(created), minute(created), count(*) FROM `delivery` WHERE `type_id`=1 AND `created`>=`2014-05-19 00:00:00` AND `created`<=`2014-05-19 23:59:59` GROUP BY day(created),hour(created),minute(created) ORDER BY
day(created),hour(created),minute(created);
这在续集专业版中完美运行,但在快递中导致以下错误:
Error: ER_PARSE_ERROR: 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 'query' at line 1
at Query.Sequence._packetToError
任何帮助都将受到高度赞赏。
提前致谢!
答案 0 :(得分:0)
在MySQL查询中使用datetime
值时,必须使用
'2014-05-19 00:00:00' //(surrounded by '')
而不是
`2014-05-19 00:00:00` //(surrounded by ``)
因此,您的查询应如下所示:
SELECT
day(created), hour(created), minute(created), count(*)
FROM
delivery
WHERE
type_id = 1
AND created >= '2014-05-19 00:00:00'
AND created <= '2014-05-19 23:59:59'
GROUP BY day(created) , hour(created) , minute(created)
ORDER BY day(created) , hour(created) , minute(created);