# Campaign Update Console Command Causes SQL Error

**URL:** <https://forum.mautic.org/t/campaign-update-console-command-causes-sql-error/1942>\
**Category:** Product Support\
**Created:** [June 10, 2015, 1:32pm UTC](https://forum.mautic.org/t/campaign-update-console-command-causes-sql-error/1942 "2015-06-10T13:32:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![petertl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/petertl/32/511_2.png) [@petertl](https://forum.mautic.org/u/petertl)\
**Post date:** [June 10, 2015, 1:32pm UTC](https://forum.mautic.org/t/campaign-update-console-command-causes-sql-error/1942/1 "2015-06-10T13:32:48Z")

</div>

Hi,  
  
  
  
I setup a new 1.1.2 Mautic system from scratch. To test it, I imported leads and created a campaign which sends out an email an tracks a landing page.  
  
  
  
The leads were successfully added to the campaign, but the emails were not sent out - so I manually fired to console commands via SSH:

Code:

php mautic/app/console mautic:leadlists:update --env=prod php mautic/app/console mautic:campaigns:update --env=prod php mautic/app/console mautic:campaigns:trigger --env=prod

  
The first and the last one finished properly, but the second one caused two error messages in the SSH terminal:  

Code:

[DoctrineDBALDBALException] An exception occurred while executing 'SELECT max(ll.lead\_id) as max\_id, count(distinct(ll.lead\_id)) as lead\_count FROM lead\_lists\_leads ll WHERE (ll.leadlist\_id IN ()) AND (ll.manually\_removed = ?) AND (ll.date\_added \<= '2015-06-10 14:30:49') AND (ll.lead\_id NOT IN (SELECT cl.lead\_id FROM campaign\_leads cl WHERE cl.campaign\_id = 1)) ORDER BY ll.lead\_id ASC' with params [0]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQLserver version for the right syntax to use near')) AND (ll.manually\_removed = 0) AND (ll.date\_added \<= '2015-06-10 14:30:49') AN' at line 1

Code:

[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 (ll.manually\_removed = 0) AND (ll.date\_added \<= '2015-06-10 14:30:49') AN' at line 1

  
Any ideas?  
  
Peter

---

<div class="post-metadata">

**Author:** ![petertl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/petertl/32/511_2.png) [@petertl](https://forum.mautic.org/u/petertl)\
**Post date:** [June 10, 2015, 1:32pm UTC](https://forum.mautic.org/t/campaign-update-console-command-causes-sql-error/1942/2 "2015-06-10T13:32:48Z")

</div>

Hi,

I setup a new 1.1.2 Mautic system from scratch. To test it, I imported leads and created a campaign which sends out an email an tracks a landing page.

The leads were successfully added to the campaign, but the emails were not sent out - so I manually fired to console commands via SSH:

`php mautic/app/console mautic:leadlists:update --env=prod
php mautic/app/console mautic:campaigns:update --env=prod
php mautic/app/console mautic:campaigns:trigger --env=prod`

The first and the last one finished properly, but the second one caused two error messages in the SSH terminal:

`[DoctrineDBALDBALException]
An exception occurred while executing 'SELECT max(ll.lead_id) as max_id, count(distinct(ll.lead_id)) as lead_count FROM lead_lists_leads ll WHERE (ll.leadlist_id IN ()) AND (ll.manually_removed = ?) AND (ll.date_added <= '2015-06-10 14:30:49') AND (ll.lead_id NOT IN (SELECT cl.lead_id FROM campaign_leads cl WHERE cl.campaign_id = 1)) ORDER BY ll.lead_id ASC' with params [0]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQLserver version for the right syntax to use near')) AND (ll.manually_removed = 0) AND (ll.date_added <= '2015-06-10 14:30:49') AN' 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 (ll.manually_removed = 0) AND (ll.date_added <= '2015-06-10 14:30:49') AN' at line 1`

Any ideas?

Peter

---

<div class="post-metadata">

**Author:** ![gmillard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gmillard/32/5_2.png) [@gmillard](https://forum.mautic.org/u/gmillard)\
**Post date:** [June 10, 2015, 2:03pm UTC](https://forum.mautic.org/t/campaign-update-console-command-causes-sql-error/1942/3 "2015-06-10T14:03:21Z")

</div>

Hi Peter,

Do you have lead lists assigned to the campaign or just using a form as the lead source?

The error is coming from `ll.leadlist_id IN ()` which makes me wonder if there are any lists assigned to the campaign. We need to add a check to prevent that SQL error.

I just submitted a patch to fix this at [https://github.com/mautic/mautic/pull/533](https://github.com/mautic/mautic/pull/533). Would you be willing to apply it and test then make a comment in the PR on the result. You can simply manually make the changes listed in [https://github.com/mautic/mautic/pull/533/files](https://github.com/mautic/mautic/pull/533/files) or click the view button for each file then raw and copy the entire file’s contents to the associated file.

Thanks!  
Alan

---

<div class="post-metadata">

**Author:** ![petertl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/petertl/32/511_2.png) [@petertl](https://forum.mautic.org/u/petertl)\
**Post date:** [June 10, 2015, 2:13pm UTC](https://forum.mautic.org/t/campaign-update-console-command-causes-sql-error/1942/4 "2015-06-10T14:13:27Z")

</div>

Hi Alan,

Thank you! Your patch resolved the error message. You were right, I created a campaign with a form assigned and no lead list.

Thanks again,

Peter

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [February 2, 2020, 10:59pm UTC](https://forum.mautic.org/t/campaign-update-console-command-causes-sql-error/1942/5 "2020-02-02T22:59:35Z")

</div>


