title: Advanced Mysql query with case and when
body: <p>I'm working in one scenario where I need to display few records from the table in which id does not exist in the list.</p>
  
  <pre><code>SELECT * FROM contract 
  WHERE `id` NOT IN ( 
      CASE 
          WHEN type = 1 THEN '159,154' 
          WHEN type = 2 THEN '' 
          WHEN type = 3 THEN '' 
      END 
  ) 
  ORDER BY id DESC 
  </code></pre>
  
  <p>Over here you can see that if contract type = 1 then the result should not display 159 &amp; 154 records from the table. But 154 number record is also coming in the result which should not.</p>
  
  <p>Any help appreciated!</p>