title: select all customers which have no services
body: <p>I have two MySQL tables, <code>tblclients</code> and <code>tblservices</code>. Each record in <code>tblservices</code> represents a service we provide for a client and there can be many services per client. Both tables have a 'status' field, in <code>tblclients</code> it is either 'active' or 'inactive' and in <code>tblservices</code> it is either 'active' or 'terminated'. </p>
  
  <p>I need to write a SQL statement which will output a list of active clients which have no active services so that I can write a php script which will make the clients inactive.</p>
  
  <p>I understand how to list all clients which have a service which is terminated, but I don't understand how to list clients which have no active services (all terminated). Is there a way to query this in SQL using subqueries or the like. So far I have:</p>
  
  <pre><code>SELECT tblclients.id, tblclients.email, tblservices.status 
  FROM tblclients JOIN tblservices on tblclients.id = tblservices.userid 
  WHERE tblclients.status="active" AND tblservices.status="terminated";
  </code></pre>