title: Split string at specific character SQL-Standard
body: <p>In my SQL statement I have to extract a substring from a string at the character '_'. Strings can be for example 'A_XXX' 'AB_XXX' 'ABC_XXXX', so the extracted substrings should be like 'A' 'AB' 'ABC'.</p>
  
  <p>In Oracle this is easy with the substr() and instr() functions:</p>
  
  <pre><code>select substr('AB_XXX', 1, instr('AB_XXX', '_')-1) as substring
  from dual;
  </code></pre>
  
  <p>The result would be:</p>
  
  <pre><code>SUBSTRING
  ------------------------
  AB
  </code></pre>
  
  <p>I need this query to check if a specific substring is in an array of strings. </p>
  
  <p>The whole query would look like:</p>
  
  <pre><code>select 'AB_XXX' from dual
  where (instr('ABC_AB_A', substr('AB_XXX', 1, instr('AB_XXX', '_')-1))&gt;0);
  </code></pre>
  
  <p>Is there a way to write it in SQL-Standard?</p>
  
  <p>Thanks in advance for your help.</p>
  
  <p>Edit:</p>
  
  <p>If PostgreSQL provides an alternative function, it also helps. The rest could be solved with e.g. IN.
  The really important part is to get the substring.</p>