Re: SELECT query experts, anyone?

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: Teemu Juntunen <teemu(dot)juntunen(at)e-ngine(dot)fi>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: SELECT query experts, anyone?
Date: 2008-08-20 13:10:38
Message-ID: 48AC17CE.5030604@wildenhain.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Teemu Juntunen wrote:
> Hi Experts,
>
> is threre any way to SELECT values in columns instead of rows? For
> example select products and their manufacters in the followin way:
>
> product1; manufacturer1; manufacturer2;,,, manufacturerN
> product2; manufacturer3;
> product3; manufacturer1;.. manufacturerN-1
>
> With a function you could put the product manufacturers in one string,
> but I would like to have them in columns.
>
> How about arrays. Is there a way to SELECT values in an array to columns?

This should work:

SELECT product,array(SELECT manufacturer FROM manufacturers WHERE
manufacturer_id=products.manufacturer_id) WHERE ...

or something along the lines of the above.

Regards
Tino

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Grittner 2008-08-20 13:10:59 Re: Regarding access to a user
Previous Message Tom Lane 2008-08-20 13:05:48 Re: Restarting with pg_ctl, users, and passwords.