title: Is it possible in SQL to match a LIKE from a list of records in a subquery?
body: <p>Using these tables, as a sample:</p>
  
  <p><strong>CodeVariations</strong>:</p>
  
  <pre><code>CODE
  -----------
  ABC_012
  DEF_024
  JKLX048
  </code></pre>
  
  <p><strong>RegisteredCodes</strong>:</p>
  
  <pre><code>CODE       AMOUNT
  --------   ------
  ABCM012         5
  ABCK012        25
  JKLM048        16
  </code></pre>
  
  <p>Is it possible to write a query to retrieve all rows in <em>RegisteredCodes</em> when CODE matches a pattern in <strong>any</strong> row of the <em>CodeVariations</em> table? That is, any row that matches a LIKE pattern of either <code>'ABC_012'</code>, <code>'DEF_024'</code> or <code>'JKLX048'</code></p>
  
  <p>Result should be:</p>
  
  <pre><code>CODE       AMOUNT
  --------   ------
  ABCM012         5
  ABCK012        25
  </code></pre>
  
  <p>I'm using PostgreSQL, but it would be interesting to know if it's possible to do this in a simple query for either PostgreSQL or any other DB.</p>