Query Advice

Поиск
Список
Период
Сортировка
От Gary Chambers
Тема Query Advice
Дата
Msg-id alpine.DEB.2.20.1703301350250.17355@websrv.gogca.com
обсуждение исходный текст
Ответы Re: Query Advice
Re: Query Advice
Re: Query Advice
Список pgsql-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.



В списке pgsql-sql по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: daisychain rows to detect value
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Query Advice