Table lookup in Postgresql

Поиск
Список
Период
Сортировка
От Mehmet Yunt
Тема Table lookup in Postgresql
Дата
Msg-id CAAe8C7Tri4q29ESMjBytv0Fy=NzFiamMpVqXHvrb+NqaAMueHg@mail.gmail.com
обсуждение исходный текст
Ответы Re: Table lookup in Postgresql
Список pgsql-novice
Hi All

I have a table that contains arrays of integers.  These integers
are code names for quantities. Each quantity (hence integer) has also
an associated index in a bigger array.

For example

Row in Table A
{5,6,7,8,9}

Table B contains the look up for the indices

Val   Idx
5      10
6       1
7       9
8       2
9       3

What I would like to do is to create a row in table C for all rows in table A that contains a vector where the indices corresponding to the elements in the A table are 1 and the remainder are 0 like

{ 0,1, 1,0,0,1,0,0,1,1}

where the maximum length of this vector is known

How can I best do it in Postgresql? Should I loop using PL/PgSQL?

Thanks
Mehmet


 

В списке pgsql-novice по дате отправления:

Предыдущее
От: simonyanderson
Дата:
Сообщение: Re: How to Recover iPhone Contacts You Lost Somehow?
Следующее
От: David Johnston
Дата:
Сообщение: Re: Table lookup in Postgresql