pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter_e@gmx.net>
To: Thilo Mezger <mezger@innominate.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] turning a table by 90 degrees
Date: Thu, 9 Dec 1999 01:18:44 +0100 (CET)
Message-ID: <Pine.LNX.4.20.9912090107520.389-100000@localhost.localdomain> (raw)
In-Reply-To: <news2mail-82l4el$9g9$2@mate.bln.innominate.de>

On 1999-12-08, Thilo Mezger mentioned:

> hi,
> 
> i've got a table like this (plus a primary key and some other fields):
> 
> key      | value   | custid
> ---------+---------+---------
> name     | peter   | 2
> age      | 123     | 2
> foo      | bar     | 2
> [...]    |         |
> name     | john    | 3
> [...]
> 
> you can think of a table which is turned by 90 degrees.  this can be
> quite useful when you don't know in advance what key/values pairs you
> have to store.
> 
> now it would be nice to find a query which returns this result for
> custid=2:
> 
> name  | age | foo
> ------+-----+------
> peter | 123 | bar

I don't see why a table
SELECT * FROM your_table WHERE custid = 2;
would be any different. Just switch the column and row addressing logic in
your application.

key      | value   | custid
---------+---------+---------
name     | peter   | 2
age      | 123     | 2
foo      | bar     | 2

There's really no way to do what you suggested.

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden





view thread (2+ messages)

Message-ID: <Pine.LNX.4.20.9912090107520.389-100000@localhost.localdomain>
Permalink:  ../Pine.LNX.4.20.9912090107520.389-100000@localhost.localdomain/
Also on:    postgresql.org/message-id/Pine.LNX.4.20.9912090107520.389-100000@localhost.localdomain

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: peter_e@gmx.net, mezger@innominate.de
  Subject: Re: [SQL] turning a table by 90 degrees
  In-Reply-To: <Pine.LNX.4.20.9912090107520.389-100000@localhost.localdomain>
  References: <news2mail-82l4el$9g9$2@mate.bln.innominate.de> <Pine.LNX.4.20.9912090107520.389-100000@localhost.localdomain>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox