Thread: Query problem

Query problem

From
Rado Petrik
Date:
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

From
Richard Huxton
Date:
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

From
Bruno Wolff III
Date:
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.