Обсуждение: Query problem

Поиск
Список
Период
Сортировка

Query problem

От
Rado Petrik
Дата:
Hi,  I have table "user".

table "user"

id      bit(dec)    bit(bin) 
-----------------------------1       1             12       3            11 3       12         1100


and I need query  - > 

SELECT "output" FROM user WHERE id = 1 OR id = 2  or id = 3 
output = (1111) 

In programing language output = 

id(1..3) { $output = ( bit | $output );     
}

How write query ? . Thanks 





-- 
Rado Petrik <r.p@szm.sk>




Re: Query problem

От
Richard Huxton
Дата:
On Tuesday 19 August 2003 14:02, Rado Petrik wrote:
> id      bit(dec)    bit(bin)
> -----------------------------
>  1       1             1
>  2       3            11
>  3       12         1100
>
>
> and I need query  - >
>
> SELECT "output" FROM user WHERE id = 1 OR id = 2  or id = 3
> output = (1111)

PG supports bit-strings which I guess are designed for exactly this situation. 
See the "data types" section of the manual for details.

--  Richard Huxton Archonet Ltd


Re: Query problem

От
Bruno Wolff III
Дата:
On Tue, Aug 19, 2003 at 15:02:24 +0200, Rado Petrik <r.p@szm.sk> wrote:
> 
> In programing language output = 
> 
> id(1..3) { 
>     $output = ( bit | $output );     
> }
> 
> How write query ? . Thanks 

You probably want to write a custom aggregate function to do this.