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. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general