From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Thilo Mezger <mezger(at)innominate(dot)de> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: [SQL] turning a table by 90 degrees |
Date: | 1999-12-09 00:18:44 |
Message-ID: | Pine.LNX.4.20.9912090107520.389-100000@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 1999-12-09 01:15:56 | Re: [SQL] timestamp/now in views |
Previous Message | Graeme Merrall | 1999-12-08 23:18:47 | timestamp/now in views |