From: | Sergey Konoplev <gray(dot)ru(at)gmail(dot)com> |
---|---|
To: | ssylla <stefansylla(at)gmx(dot)de> |
Cc: | pgsql-sql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: select on many-to-many relationship |
Date: | 2012-11-28 00:27:21 |
Message-ID: | CAL_0b1vE8Fvakoc8crF2ZwUK7mDVzTBfiGf4-1PekRq2Om598A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Tue, Nov 27, 2012 at 2:13 AM, ssylla <stefansylla(at)gmx(dot)de> wrote:
> id_project|id_product
> 1|1
> 1|2
> 2|1
>
> How can I create an output like this:
> id_project|id_product1|id_product2
> 1|1|2
> 2|1|NULL
You can use the crostab() function from the tablefunc module
(http://www.postgresql.org/docs/9.2/static/tablefunc.html) It does
exactly what you need.
>
>
>
> --
> View this message in context: http://postgresql.1045698.n5.nabble.com/select-on-many-to-many-relationship-tp5733696.html
> Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
--
Sergey Konoplev
Database and Software Architect
http://www.linkedin.com/in/grayhemp
Phones:
USA +1 415 867 9984
Russia, Moscow +7 901 903 0499
Russia, Krasnodar +7 988 888 1979
Skype: gray-hemp
Jabber: gray(dot)ru(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | JORGE MALDONADO | 2012-11-28 18:33:15 | Joining several rows into only one |
Previous Message | Виктор Егоров | 2012-11-27 17:48:22 | Re: select on many-to-many relationship |