title: Comparing substrings in same table
body: <p>I need to run a query that will give me the list of all entries in one column that is NOT LIKE any of the entries in another column, i.e.:</p>
  
  <pre><code>SELECT DISTINCT columnA
  FROM tableA
  WHERE columnA NOT LIKE (SELECT columnB FROM tableA)
  </code></pre>
  
  <p>Obviously, the above query doesn't work, I'm providing it only in the hopes that it will clarify what I'm trying to achieve. So, as an example, say that my columns contain the following:</p>
  
  <pre><code>COLUMNA:
  ABCD
  ABCE
  BCDE
  BCDF
  BCDEF
  GHIJ
  GHIK
  
  COLUMNB:
  ABC
  DEF
  HIJ
  </code></pre>
  
  <p>My desired results would be:</p>
  
  <pre><code>BCDE
  BCDF
  GHIK
  </code></pre>
  
  <p>There are a total of 396 values in column in the table, so just entering the values manually is not feasible. In addition, as noted in the example, the values in columnB would always be substrings of the values in columnA, so I also need to have my query do the comparison with that in mind.</p>
  
  <p>Thanks in advance for any help anyone can offer, and also apologies if this question has already been answered elsewhere - I did a search but wasn't able to find anything that I could interpret as addressing this specific requirement.</p>
  
  <p><em><strong></em> ADDING NEW INFO <em>*</em>*</strong></p>
  
  <p>So, as noted, I made a HUGE mistake in that the two columns are in different tables. That said, though, it was easy enough to modify califax's suggestion below as follows:</p>
  
  <p>SELECT DISTINCT COLUMNA
  FROM TABLE1 T1
  LEFT JOIN TABLE2 T2 ON
  T1.COLUMNA LIKE '%' + T2.COLUMNB + '%'
  AND T2.COLUMNB IS NULL</p>
  
  <p>However, it's still returning the full list of entries from COLUMNA. I've confirmed that there are entries in COLUMNB that are substrings of the entries in COLUMNA - any ideas why this isn't filtering?</p>
  
  <p>Thanks.</p>