title: Text to List in SQL
body: <p>Is there any way on how to convert a comma separated text value to a list so that I can use it with 'IN' in SQL? I used PostgreSQL for this one.</p>
  
  <p>Ex.:</p>
  
  <pre><code>select location from tbl where 
  location in (replace(replace(replace('[Location].[SG],[Location].[PH]', ',[Location].[', ','''), '[Location].[', ''''), ']',''''))
  </code></pre>
  
  <p>This query:</p>
  
  <pre><code>select (replace(replace(replace('[Location].[SG],[Location].[PH]', ',[Location].[', ','''), '[Location].[', ''''), ']',''''))
  </code></pre>
  
  <p>produces 'SG','PH'</p>
  
  <p>I wanted to produce this query:</p>
  
  <pre><code>select location from tbl where location in ('SG','PH')
  </code></pre>
  
  <p>Nothing returned when I executed the first query. The table has been filled with location values 'SG' and 'PH'.</p>
  
  <p>Can anyone help me on how to make this work without using PL/pgSQL?</p>