title: Understanding ILIKE ANY element of an array - postgresql
body: <p>I have to select all the lines in a table (let's call it <code>mytable</code>) for which the value in a given column (let's call it <code>mycolumn</code>) is <strong>not</strong> equal to 'A' and <strong>not</strong> equal to 'S'.</p>
  
  <p>So I tried something like</p>
  
  <pre><code>SELECT * FROM mytable WHERE mycolumn NOT ILIKE ANY(ARRAY['A','S'])
  </code></pre>
  
  <p>I prefer the use of <code>ILIKE</code> instead of the use of <code>=</code> to test string equalities because the values 'A' and 'S' may come in lower-case in my data, so I want the values 's' and 'a' to be excluded as well.</p>
  
  <p>Strangely enough, the query above did return some lines for which the value inside <code>mycolumn</code> was equal to 'A'. I was very surprised.</p>
  
  <p>Therefore, to understand what was happening I tried to carry out a very simple logical test:</p>
  
  <pre><code>SELECT ('A' ILIKE ANY(ARRAY['A','S'])) as logical_test ;
  </code></pre>
  
  <p>The statement above returns TRUE, which was expected.</p>
  
  <p>But the following statement also returns TRUE and this is where I'm lost:</p>
  
  <pre><code>SELECT ('A' NOT ILIKE ANY(ARRAY['A','S'])) as logical_test ;
  </code></pre>
  
  <p>Could someone explain why <code>'A' NOT ILIKE ANY(ARRAY['A','S'])</code> is considered TRUE by PostgreSQL?</p>