agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Gary Chambers <gwchamb@gwcmail.com>
To: PostgreSQL SQL Mailing List <pgsql-sql@postgresql.org>
Subject: Query Advice
Date: Thu, 30 Mar 2017 14:03:22 -0400 (EDT)
Message-ID: <alpine.DEB.2.20.1703301350250.17355@websrv.gogca.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
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
view thread (7+ messages) latest in thread
Message-ID: <alpine.DEB.2.20.1703301350250.17355@websrv.gogca.com>
Permalink: ../alpine.DEB.2.20.1703301350250.17355@websrv.gogca.com/
Also on: postgresql.org/message-id/alpine.DEB.2.20.1703301350250.17355@websrv.gogca.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: gwchamb@gwcmail.com
Subject: Re: Query Advice
In-Reply-To: <alpine.DEB.2.20.1703301350250.17355@websrv.gogca.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox