title: CASE...WHEN in WHERE clause in Postgresql
body: <p>My query looks like:</p>
  
  <pre><code>SELECT * 
  FROM table 
  WHERE t1.id_status_notatka_1 = ANY (selected_type)  
   AND t1.id_status_notatka_2 = ANY (selected_place) 
  </code></pre>
  
  <p>here I would like to add CASE WHEN 
  so my query is:</p>
  
  <pre><code>    SELECT *  
      FROM table 
      WHERE t1.id_status_notatka_1 = ANY (selected_type)  
        AND t1.id_status_notatka_2    = ANY (selected_place) 
        AND CASE 
              WHEN t2.id_bank = 12 THEN t1.id_status_notatka_4 = ANY (selected_effect) 
           END
  </code></pre>
  
  <p>but it doesn't work. The syntax is good but it fails in searching for anything. So my question is - how use CASE WHEN in WHERE clause. Short example: if a=0 then add some condition to WHERE (AND condition), if it's not then don't add (AND condition)</p>