title: SQL SELECT query for two values within same field
body: <p>I am fairly new to SQL queries and I am having trouble performing a query on an already running database. </p>
  
  <p>I need to run two queries, first to check who has signed up 3 days ago and has not made any orders and has not receieved an email giving them an offer. This works great. </p>
  
  <p>The next query is to check that a customer has signed up 7 days ago, not made any orders and has receieved the 3 day email. I can get it to do that but I also need to check that they have not already receieved the second email and this is the part that is confusing me. Even when the customer has been sent the 2 email when I run the query again they still appear.</p>
  
  <pre><code>$sql = "
      SELECT c.customerID, c.email, c.forename, c.date 
        FROM customers c
         LEFT OUTER JOIN orders_headers o ON o.customerID=c.customerID 
         LEFT OUTER JOIN no_order_mail_sent m ON m.customerID=c.customerID 
         LEFT OUTER JOIN automated_email_discount e ON e.customerID=c.customerID 
       WHERE m.customerID IS NULL
         AND o.customerID IS NULL
         AND e.customerID IS NOT NULL 
         AND e.discount_code_id='1'
         AND e.discount_code_id!='2' 
         AND STR_TO_DATE(c.date, '%Y%m%d') ='".date('Y-m-d', strtotime('-'.$days.'days'))."'
  ";
  </code></pre>
  
  <p>The two discount codes are 1 for first email (5% discount) and 2 for the second email (10% discount) which is the value I am trying to check for that is within the database.</p>
  
  <p>I am running the query in PHP. Any help would be grateful.</p>
  
  <p>Thanks in advance.</p>