title: Getting a list value for every row (list of ids from another table)
body: <p>I have a quite ordinary table with a foreign key to another table; for example:</p>
  
  <pre><code>CREATE TABLE table_a (
    id serial NOT NULL,
    name text,
    CONSTRAINT table_a_pkey PRIMARY KEY (id)
  );
  CREATE TABLE table_b (
    id serial NOT NULL,
    a_id integer,       -- The foreign key
    CONSTRAINT table_b_pkey PRIMARY KEY (id),
    CONSTRAINT table_b_a_id_fkey FOREIGN KEY (a_id)
        REFERENCES table_a (id) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE NO ACTION
  );
  INSERT INTO table_a
       VALUES (1, 'First row');
  -- 2 entries in table_b which refer to the existing table_a row:
  INSERT INTO table_b
       VALUES (11, 1), (12, 1);
  </code></pre>
  
  <p>Now I'd like to have a view which gives me a list of all ids of <code>table_b</code> rows which refer to the current <code>table_a</code> row:</p>
  
  <pre><code>SELECT a.name,
         (SELECT b.id
            FROM table_b b
           WHERE b.id = a.id) AS b_ids
    FROM table_a a;
  </code></pre>
  
  <p>However, the <code>b_ids</code> column is empty; I'd like to have some kind of list there, containing the values 11 and 12.</p>
  
  <p>Somewhere I read that subselects can only yield one column (ok for me in this case) <strong>and only one row</strong> (which would explain that the above query doesn't work for me). If this is true - how can this be done instead? Or do I really need to issue <code>SELECT</code> requests for every single <code>table_a</code> row in my program?</p>
  
  <p>I'd like this to work with PostgreSQL 9.1 and 9.3.</p>