本机查询中的学说 Add_date
doctrine Add_date in native query
我想 select 使用本机查询和 DATE_ADD 来自 table 的数据,但我总是遇到错误,
这是我的 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
有什么想法吗
DATE_ADD
函数语法错误
将 DATE_ADD(p.date_send,7,'DAY')
更改为 DATE_ADD(p.date_send, INTERVAL 7 DAY)
我想 select 使用本机查询和 DATE_ADD 来自 table 的数据,但我总是遇到错误,
这是我的 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
有什么想法吗
DATE_ADD
函数语法错误
将 DATE_ADD(p.date_send,7,'DAY')
更改为 DATE_ADD(p.date_send, INTERVAL 7 DAY)