title: PostgreSQL: retrieving multiple array elements
body: <p>Let's say we have a query like:</p>
  
  <pre><code>SELECT regexp_split_to_array('foo,bar', ',');
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>+-----------------------+
  | regexp_split_to_array |
  +-----------------------+
  | {foo,bar}             |
  +-----------------------+
  (1 row)
  </code></pre>
  
  <p>To access a single element of an array we can use code like:</p>
  
  <pre><code>SELECT (regexp_split_to_array('foo,bar', ','))[1];
  </code></pre>
  
  <p>Which will return:</p>
  
  <pre><code>+-----------------------+
  | regexp_split_to_array |
  +-----------------------+
  | foo                   |
  +-----------------------+
  (1 row)
  </code></pre>
  
  <p>Or use slices like:</p>
  
  <pre><code>SELECT (regexp_split_to_array('foo,bar', ','))[2:];
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>+-----------------------+
  | regexp_split_to_array |
  +-----------------------+
  | {bar}                 |
  +-----------------------+
  (1 row)
  </code></pre>
  
  <p>However, when I try to access 2 elements at once, like:</p>
  
  <pre><code>SELECT (regexp_split_to_array('foo,bar', ','))[1,2];
  </code></pre>
  
  <p>or</p>
  
  <pre><code>SELECT (regexp_split_to_array('foo,bar', ','))[1][2];
  </code></pre>
  
  <p>or any other syntax, I receive an error:</p>
  
  <pre><code>ERROR:  syntax error at or near ","
  </code></pre>
  
  <p>Is it possible to retrieve two different and not adjacent elements of an array in PostgreSQL?</p>