title: MYSQL where statements
body: <p>I am making a system that checks connectivity on SSL adresses. For this, I use two tables:</p>
  
  <pre><code>ssllist
  - id
  - dnsname
  - active (0 or 1)
  
  sslresult
  - id
  - ssllist_id
  - starttime
  - result (0 or 1)
  </code></pre>
  
  <p>By default, my system checks all entries in ssllist every 30 minutes, but I also want it to check the entries every minute that match these rules:</p>
  
  <pre><code>- Active=1
  AND(
    - no results of this entry in sslresult
  OR
    - had an error in the last half hour (result=0)
  OR
    - did not have ANY results in the last half hour
  )
  </code></pre>
  
  <p>So, I made this query to comply to the first 3 rules:</p>
  
  <pre><code>SELECT
  ssllist.id as id,
  ssllist.dnsname
  FROM ssllist
  LEFT JOIN sslresult
  ON ssllist.id = sslresult.ssllist_id
  WHERE 
  ssllist.active=1 
  AND
  (
    (sslresult.result = 0 AND sslresult.starttime &gt; (UNIX_TIMESTAMP() - 1800)  
    OR 
    sslresult.ssllist_id is null
  )
  GROUP BY id
  </code></pre>
  
  <p>However I don't know how to add the last "where" statement, so "get all ssllist.id's which DID NOT have a sslresult in the last half hour).</p>
  
  <p>How to do that?</p>