« Server replication in Postgres 9.1 | Main | rEFIt - Booting Linux with Bootcamp »

December 07, 2011

Cast the results of a subquery as an array then join as a string

select p.*, 
array_to_string(array(select first_name||' '||last_name from publications.authors a where a.publication_id = p.id), ',') as aus ,
array_to_string(array(select first_name||' '||last_name from publications.editors e where e.publication_id = p.id), ',') as eds
from publications.publication_as_ris3 p
where p.av in ('Forthcoming','Published') and p.id in ((select publication_id from publications.authors where first_name = 'Tony' and last_name = 'Kinder')union(select publication_id from publications.editors where first_name = 'Tony' and last_name = 'Kinder'))

Tags: PostgreSQL

Posted by pj at December 7, 2011 12:31 PM

Comments