【问题标题】:doctrine Add_date in native query本机查询中的教义 Add_date
【发布时间】:2016-04-13 05:56:16
【问题描述】:

我想使用本机查询和 DATE_ADD 从表中选择数据,但总是出错,

这是我的 sql 请求:

 $qb = $this->_em->createNativeQuery("select  Coalesce (sum(p.nb_sms*p.nb_destination),0)  as multiplesms , sum(p.nb_fax) as nbFax, sum(p.nb_Mail) as nbMail FROM push p WHERE p.id_user=$id and DATE_ADD(p.date_send,7,'DAY') > CURRENT_DATE() and p.statut>0 order by p.date_send  Desc", $rsm);

我遇到了一个错误

SQLSTATE[42000]: Syntax error or access violation: 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 '7,'DAY') > CURRENT_DATE() and p.statut>0 order by p.date_send Desc' at line 1

有什么建议

【问题讨论】:

标签: symfony doctrine-orm doctrine-native-query


【解决方案1】:

DATE_ADD 函数语法错误
DATE_ADD(p.date_send,7,'DAY') 更改为DATE_ADD(p.date_send, INTERVAL 7 DAY)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-27
    • 2018-07-11
    • 2015-11-30
    相关资源
    最近更新 更多