drcmg28484 2015-09-14 15:06
浏览 76
已采纳

BETWEEN运算符mySQL PHP

All,

Not sure why I am getting the error whilst running the following query:

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 is in the following format: 2015-06-01 14:38:46 I simply want to get the result between Now() and the previous year. (In the UK, we have financial year between april to next year april.

The error is:

#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 

Any ideas?

  • 写回答

1条回答 默认 最新

  • dstxpei5823 2015-09-14 15:28
    关注

    The AND clause you're looking for should look as follows:

    ...
    AND R.date_received BETWEEN STR_TO_DATE('01,04,2014','%d,%m,%Y') AND NOW()
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有谁能看看我coe文件到底哪儿有问题吗?
  • ¥20 我的这个coe文件到底哪儿出问题了
  • ¥15 matlab使用自定义函数时一直报错输入参数过多
  • ¥15 设计一个温度闭环控制系统
  • ¥100 rtmpose姿态评估
  • ¥15 java 通过反射找路径下的类,打包后就找不到
  • ¥15 通联支付网上收银统一下单接口
  • ¥15 angular有偿编写,
  • ¥15 centos7系统下abinit安装时make出错
  • ¥15 hbuildex运行微信小程序报错