1

I want to select data from table using native query and DATE_ADD but always I got an errors,

this is my sql request:

 $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);

I got an error

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

any idea please

Majdi Taleb
  • 731
  • 3
  • 9
  • 26

1 Answers1

2

mistake in DATE_ADD function syntax
change DATE_ADD(p.date_send,7,'DAY') to DATE_ADD(p.date_send, INTERVAL 7 DAY)

Max P.
  • 5,579
  • 2
  • 13
  • 32