Newsletter Plugin MySql database query not working as hoped

By JeffC - January 27, 2017

Hi

I am trying to set up a database query so that a list is created to send to subscribers where Publication contains "MAG1" but not necessarily only MAG1.

For example:
MAG1 would be included in the list
MAG1 MAG2 would be included in the list
MAG2 would NOT be included in the list 

After sending my message I received some failed delivery notices (as is normal) but I noticed some of the failed messages were from subscribers where publication is MAG2 only.

Please can someone tell me where I have gone wrong, here's my code:

SELECT contacts.num FROM  <?php echo $TABLE_PREFIX ?>_nlb_subscribers AS subscribers
LEFT JOIN  <?php echo $TABLE_PREFIX ?>contacts AS contacts
ON  contacts.email_1_sales = subscribers.email
OR contacts.email_2_sales = subscribers.email
OR contacts.email_1_copy = subscribers.email
OR contacts.email_2_copy = subscribers.email
OR contacts.email_1_invoice = subscribers.email
OR contacts.email_2_invoice = subscribers.email
OR contacts.email_1_delivery = subscribers.email
OR contacts.email_2_delivery = subscribers.email
OR contacts.email_1_other = subscribers.email
OR contacts.email_2_other = subscribers.email
WHERE contacts.`title` != "" AND 
#ADD YOUR CUSTOM WHERE STATEMENT HERE#
contacts.publications LIKE'%MAG1%' AND subscribers.confirmed = '1'
ORDER BY subscribers.email ASC

Thanks

Jeff