Re: Turning column into row

From: "Wm(dot) G(dot) Urquhart" <wgu(at)wurquhart(dot)co(dot)uk>
To: "Tille, Andreas" <TilleA(at)rki(dot)de>
Cc: PostgreSQL SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Turning column into row
Date: 2002-05-22 12:40:54
Message-ID: Pine.LNX.4.44.0205221335160.5109-100000@mailer.wurquhart.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 22 May 2002, Tille, Andreas wrote:

> Hello,
>
> I'm afraid this is a blody beginners question but I have no idea how
> to perform a search sanely in the list archive.
>
> I have a Table of certain items
>
> create table item (
> IdItem int,
> Item varchar(64),
> ...
> );
>
> a lookuptable which defines some properties
>
> create table property (
> IdProperty int,
> Property varchar(64)
> );
>
> and a table which defines the different properties which are possible for
> a certain item:
>
> create table tlkp_item_property (
> IdItem int,
> IdProperty int
> );
>
> So I can easily select all the properties of a certain item in a table
> where the columns contain the properties. But I want to have an output
> of the kind
>
> Item 1: Property 1, Property 2, Property 3, ...
> Item 2: <Properties of Item 2>
> ...
>
> So I have to turn the different properties according to one item into
> one field insead of one column.
>
> How to do this sanely?
>
> Kind regards
>
> Andreas.
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

Depending on how many properties you had you could include these in the
first table and remove the other two table. Using a hash value pair or
sommit similar (Value=Desc, Value=Desc) you could then do bitwise
operations on the column to extract the information you need.

Just a thought.

--
Regards,

Wm. G. Urquhart
Custom Software Solutions
http://www.wurquhart.co.uk

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tille, Andreas 2002-05-22 12:48:20 Re: Turning column into row
Previous Message Bhuvan A 2002-05-22 12:24:53 Compatibility Issue of CREATE RULE in 7.2