Re: How to join table to itself N times?

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to join table to itself N times?
Date: 2013-03-21 02:09:49
Message-ID: 1363831789057-5749125.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Matt Wilson wrote
> I got this table right now:
>
> select * from market_segment_dimension_values ;
> +--------------------------+---------------+
> | market_segment_dimension | value |
> +--------------------------+---------------+
> | geography | north |
> | geography | south |
> | industry type | retail |
> | industry type | manufacturing |
> | industry type | wholesale |
> +--------------------------+---------------+
> (5 rows)

Most likely you can solve your problem by using the "hstore" extension. I
could be more certain of this if you actually state the
requirements/use-case/business-problem.

SQL requires that you know the column structure of the output so if hstore
does not suffice you will have to execute a dynamic query in your API after
querying the dimension map table to decide how many output columns you will
need. hstore avoids that by giving you a dynamic table-in-a-column.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/How-to-join-table-to-itself-N-times-tp5749107p5749125.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2013-03-21 02:14:21 Re: How to join table to itself N times?
Previous Message AI Rumman 2013-03-21 01:20:59 Re: How to join table to itself N times?