BETWEEN 运算符 mySQL PHP
BETWEEN Operator mySQL PHP
全部,
不确定为什么在 运行 以下查询时出现错误:
SELECT COUNT(R.id) AS total
FROM request as R
INNER JOIN users AS U ON U.uin = R.engineer_uin
WHERE U.gm = 'BVG1'
AND R.date_received BETWEEN DATE_FORMAT(R.date_received,'%d %m %Y')='01 04 2014' AND DATE_FORMAT(NOW(),'%d %m %Y')
R.date_received
格式如下:2015-06-01 14:38:46
我只想得到 Now() 和前一年之间的结果。 (在英国,我们的财政年度在四月到明年四月之间。
错误是:
#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 '='01 04 2014' AND DATE_FORMAT(NOW(),'%d %m %Y')
LIMIT 0, 25' at line 5
有什么想法吗?
您要查找的 AND
子句应如下所示:
...
AND R.date_received BETWEEN STR_TO_DATE('01,04,2014','%d,%m,%Y') AND NOW()
全部,
不确定为什么在 运行 以下查询时出现错误:
SELECT COUNT(R.id) AS total
FROM request as R
INNER JOIN users AS U ON U.uin = R.engineer_uin
WHERE U.gm = 'BVG1'
AND R.date_received BETWEEN DATE_FORMAT(R.date_received,'%d %m %Y')='01 04 2014' AND DATE_FORMAT(NOW(),'%d %m %Y')
R.date_received
格式如下:2015-06-01 14:38:46
我只想得到 Now() 和前一年之间的结果。 (在英国,我们的财政年度在四月到明年四月之间。
错误是:
#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 '='01 04 2014' AND DATE_FORMAT(NOW(),'%d %m %Y')
LIMIT 0, 25' at line 5
有什么想法吗?
您要查找的 AND
子句应如下所示:
...
AND R.date_received BETWEEN STR_TO_DATE('01,04,2014','%d,%m,%Y') AND NOW()