# Database error

**URL:** <https://forum.mautic.org/t/database-error/3147>\
**Category:** Product Support\
**Created:** [January 6, 2016, 12:43pm UTC](https://forum.mautic.org/t/database-error/3147 "2016-01-06T12:43:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![felipe](https://avatars.discourse-cdn.com/v4/letter/f/90db22/32.png) [@felipe](https://forum.mautic.org/u/felipe)\
**Post date:** [January 6, 2016, 12:43pm UTC](https://forum.mautic.org/t/database-error/3147/1 "2016-01-06T12:43:21Z")

</div>

Hi there,  
  
  
  
I am having error with my mautic campaign:  
  
  
  
When I run this job:  
  
[http://mautic.manamano.com.br/extcronjob.php?mauticmanamano2015&task=mautic%3Acampaigns%3Aupdate+-f](http://mautic.manamano.com.br/extcronjob.php?mauticmanamano2015&task=mautic%3Acampaigns%3Aupdate+-f)  
  
  
  
wich is this code line:  
  
php /path/to/mautic/app/console mautic:campaigns:trigger  
  
  
  
It comes this error:  
  
An exception occurred while executing ‘SELECT max(list\_leads.lead\_id) as max\_id, count(distinct(list\_leads.lead\_id)) as lead\_count FROM tb\_lead\_lists\_leads list\_leads WHERE (list\_leads.manually\_removed = ?) AND (list\_leads.leadlist\_id IN ()) AND (list\_leads.date\_added \<= ‘2016-01-06 12:10:46’) AND (NOT EXISTS (SELECT null FROM tb\_campaign\_leads campaign\_leads WHERE (campaign\_leads.lead\_id = list\_leads.lead\_id) AND (campaign\_leads.manually\_removed = ?) AND (campaign\_leads.campaign\_id = 2)))’ with params [0, 0]:  
  
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 ')) AND (list\_leads.date\_added \<= ‘2016-01-06 12:10:46’) AND (NOT EXISTS (SELECT ’ at line 1  
  
[PDOException]  
  
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 ')) AND (list\_leads.date\_added \<= ‘2016-01-06 12:10:46’) AND (NOT EXISTS (SELECT ’ at line 1  
  
  
  
I don`t know what else to try, has anyone come across this before?  
  
  
  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![felipe](https://avatars.discourse-cdn.com/v4/letter/f/90db22/32.png) [@felipe](https://forum.mautic.org/u/felipe)\
**Post date:** [January 6, 2016, 12:43pm UTC](https://forum.mautic.org/t/database-error/3147/2 "2016-01-06T12:43:21Z")

</div>

Hi there,

I am having error with my mautic campaign:

When I run this job:  
[http://mautic.manamano.com.br/extcronjob.php?mauticmanamano2015&task=mautic%3Acampaigns%3Aupdate+-f](http://mautic.manamano.com.br/extcronjob.php?mauticmanamano2015&task=mautic%3Acampaigns%3Aupdate+-f)

wich is this code line:  
php /path/to/mautic/app/console mautic:campaigns:trigger

It comes this error:  
An exception occurred while executing ‘SELECT max(list\_leads.lead\_id) as max\_id, count(distinct(list\_leads.lead\_id)) as lead\_count FROM tb\_lead\_lists\_leads list\_leads WHERE (list\_leads.manually\_removed = ?) AND (list\_leads.leadlist\_id IN ()) AND (list\_leads.date\_added \<= ‘2016-01-06 12:10:46’) AND (NOT EXISTS (SELECT null FROM tb\_campaign\_leads campaign\_leads WHERE (campaign\_leads.lead\_id = list\_leads.lead\_id) AND (campaign\_leads.manually\_removed = ?) AND (campaign\_leads.campaign\_id = 2)))’ with params [0, 0]:  
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 ')) AND (list\_leads.date\_added \<= ‘2016-01-06 12:10:46’) AND (NOT EXISTS (SELECT ’ at line 1  
[PDOException]  
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 ')) AND (list\_leads.date\_added \<= ‘2016-01-06 12:10:46’) AND (NOT EXISTS (SELECT ’ at line 1

I don`t know what else to try, has anyone come across this before?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [January 6, 2016, 4:50pm UTC](https://forum.mautic.org/t/database-error/3147/3 "2016-01-06T16:50:43Z")

</div>

I got the same error while testing this pull request:

[https://github.com/mautic/mautic/pull/1286](https://github.com/mautic/mautic/pull/1286)

So there is a chance it fixes your issue as well. Would be great if you could test it.

---

<div class="post-metadata">

**Author:** ![felipe](https://avatars.discourse-cdn.com/v4/letter/f/90db22/32.png) [@felipe](https://forum.mautic.org/u/felipe)\
**Post date:** [January 6, 2016, 7:27pm UTC](https://forum.mautic.org/t/database-error/3147/4 "2016-01-06T19:27:31Z")

</div>

Escopecz thanks for the reply it fixed my error.

Problem I was having after fixing this issue was that my emails were not being sent. I figure the when my email config was set to queue it was not being sent. So I changed it to immediately and it works now.

thanks a lot for the help

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [January 7, 2016, 8:02am UTC](https://forum.mautic.org/t/database-error/3147/5 "2016-01-07T08:02:56Z")

</div>

@felipe that’s great! If you’ve tested the pull request, it would be really great if you could comment below the pull request for the record how the test went for you. Every additional test will speed up the release of the new version and makes Mautic more stable 😉

---

<div class="post-metadata">

**Author:** ![felipe](https://avatars.discourse-cdn.com/v4/letter/f/90db22/32.png) [@felipe](https://forum.mautic.org/u/felipe)\
**Post date:** [January 7, 2016, 2:12pm UTC](https://forum.mautic.org/t/database-error/3147/6 "2016-01-07T14:12:06Z")

</div>

@escopecz I commented below the pull request.  
thanks for the help.
