Re: table linking problem

Поиск
Список
Период
Сортировка
Искать
От
Richard Huxton
Тема
Re: table linking problem
Дата
Msg-id
200210071504.40873.dev@archonet.com
Ответ на
Список
Дерево обсуждения
table linking problem "¼B¤tºÆ" <jacky@xtrapower.net>
Re: table linking problem Richard Huxton <dev@archonet.com>
Re: table linking problem Holger Klawitter <lists@klawitter.de>
Re: table linking problem "Shridhar Daithankar" <shridhar_daithankar@persistent.co.in>
On Friday 04 Oct 2002 5:35 pm, ¼B¤tºÆ wrote:
> Hi all,
>     I have two table, follow :
>
> content
> content_id    |    material_id    |    percentage
> -----------------------------------------------------
>     1                        1                    100%
>     2                        2                    63.5%
>     2                        3                    31.5%
>     2                        4                        5%
>
> material
> material_id    |    name
> ------------------------------------------
>     1                    COTTON
>     2                    POLYESTER
>     3                    NYLON
>     4                    SPANDEX
>
> The Question is,
> How can I get like this :
> 100% COTTON
> 63.5% POLYESTER 31.5% NYLON 5% SPANDEX
>
> Can I return the string like this ?

Not using SQL - you could define a function: material_names(int4) returning 
text - provide it the "content_id" and it does the lookup and builds the 
string required. You could do this with plpgsql, it's a simple language but 
make sure you read the manual first. You could also use tcl/perl/c - see the 
procedural languages chapter for details.

The other option is to do this in the client application.

- Richard Huxton
В списке pgsql-general по дате отправления
От: Bruce Momjian
Дата:
Сообщение: Re: Stored Procedures
От: Tom Lane
Дата:
Сообщение: Re: Server locale?
FAQ