title: How to create a view in PostgreSQL containing ARRAY?
body: <p>I have a problem, I’m currently working with a Postgres database and what I want to do is to create a View from two tables. The problem is that one of the tables contains a column that is of the type “varchar ARRAY”. This column contains some sort of ID that I can use to get information from the second table.</p>
  
  <p>I have the following:</p>
  
  <p>Table 1: Person </p>
  
  <ul>
  <li>primary_name : varchar</li>
  <li>known_for_titles : varchar ARRAY  (array of t_const)  Table 2: </li>
  </ul>
  
  <p>Table 2: Movie</p>
  
  <ul>
  <li>t_const : varchar</li>
  <li>primary_title : varchar</li>
  </ul>
  
  <p>I want to create a view (actorView) that looks like this:
  -primary_name : varchar
  -famous_for : varchar ARRAY (array of titles)</p>
  
  <p>I have this SQL that does not work properly, I manages to create the view but I can’t use the select statement on its own and I can’t ask a query on the view.</p>
  
  <pre><code>CREATE or REPLACE VIEW actorView AS
      SELECT p.primary_name,
             array_agg(t.primary_title) as famous_titles
  FROM person p JOIN title t
                     ON t.t_const = any(p.known_for_titles)
      group by primary_name
  </code></pre>
  
  <p>When I try the select part of the SQL statement, it's just ends up searching in an endless loop and I have to terminate the query.</p>
  
  <p>The same thing happens when I use the whole statement. It somehow manages to create the table but I can't search for anything.</p>