Re: How to join table to itself N times? - Mailing list pgsql-general

From David Johnston
Subject Re: How to join table to itself N times?
Date
Msg-id 1363831789057-5749125.post@n5.nabble.com
Whole thread Raw
In response to How to join table to itself N times?  ("W. Matthew Wilson" <matt@tplus1.com>)
List 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.


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: State of the art re: group default privileges
Next
From: Daniel Cristian Cruz
Date:
Subject: Bad plan on a huge table query