我有一个mysql查询,但无法在PHP中运行
SELECT rev_date, rev_currency, SUM(rev_amount) AS total_amount
FROM daily_revenue
WHERE YEAR(rev_date) = YEAR(CURDATE()) AND MONTH(rev_date) = MONTH(CURDATE())
GROUP BY rev_currency, YEAR(rev_date), MONTH(rev_date)
我在PHP中尝试过它,直到它起作用,看起来它不喜欢where和group by条件:
这失败了:
WHERE YEAR(rev_date) = YEAR(CURDATE())
这有效:
WHERE rev_date = YEAR(CURDATE())
但是没有给我我想要的结果。
有什么想法吗?
答案 0 :(得分:0)
我添加了mysql错误(应该立即完成) 明确表示,我必须这样做:
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
现在可行。