Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctePy-0007Px-FB for pgsql-sql@arkaria.postgresql.org; Thu, 30 Mar 2017 18:03:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ctePy-0004jd-1o for pgsql-sql@arkaria.postgresql.org; Thu, 30 Mar 2017 18:03:30 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ctePx-0004jQ-EG for pgsql-sql@postgresql.org; Thu, 30 Mar 2017 18:03:29 +0000 Received: from mx1.gogca.com ([50.116.54.212]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ctePs-00026N-21 for pgsql-sql@postgresql.org; Thu, 30 Mar 2017 18:03:28 +0000 Received: from websrv.gogca.com (websrv.gogca.com [66.228.32.76]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.gogca.com (Postfix) with ESMTPSA id B583D1C53B for ; Thu, 30 Mar 2017 14:03:22 -0400 (EDT) Date: Thu, 30 Mar 2017 14:03:22 -0400 (EDT) From: Gary Chambers To: PostgreSQL SQL Mailing List Subject: Query Advice Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org All, Given the following tables: company ------- company_id name postal_addresses ---------------- postal_address_id company_id description addr city stprov zip I've been handling joins as such: select c.company_id, array(select concat_ws('|', pa.description, pa.addr, pa.city, pa.stprov, pa.zip) ) addrs from companies c inner join postal_addresses pa using (company_id) where company_id = 1731; Is there a better way to get the company information along with all of the addresses in a single query? This works, but it requires the additional step of splitting the addresses by the the delimiter at the application layer. Thanks for any advice you have. -- G. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql