title: How to make a conditional SQL statement
body: <p>I want to make a conditional SQL. I have one table "<code>users</code>" and it has two columns <code>(id, status)</code></p>
  
  <p><strong>I need to search for users IDs based on their status.</strong> </p>
  
  <p>For example : 
  Every 5 seconds I am querying from the database (by AJAX) as per the below description:</p>
  
  <p>Let us say that I have the below results on my wall (on html):</p>
  
  <pre><code>id1: 1
  status2: "A"
  
  id2: 2
  status2: "B"
  </code></pre>
  
  <p><strong>I need to get IDs from table "users" but exclude the IDs from database if their status haven't changed on my wall.</strong></p>
  
  <p>So the algorithm should be:</p>
  
  <pre><code>Get all IDs from table "users" but exclude the IDs (1,2) from database 
  (if and only if) their status = ("A", "B").
  </code></pre>
  
  <p>Simply, I need to retrieve all IDs including the IDs (1,2). But for the IDs (1,2): I need to retrieve them in case their corresponding statuses are NOT EQUAL ("A", "B") respectively. </p>
  
  <p>But for IDs other than (1,2) like (3,4,5,...), I need to retrieve them without any condition.</p>
  
  <p>I would greatly appreciate if the solution provides an excellent performance when the database records are huge and the check every 5 seconds.</p>