pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Using & - operator
2+ messages / 2 participants
[nested] [flat]

* Using & - operator
@ 2003-06-02 13:34  Rado Petrik <r.p@szm.sk>
  0 siblings, 1 reply; 2+ messages in thread

From: Rado Petrik @ 2003-06-02 13:34 UTC (permalink / raw)
  To: pgsql-sql

Hi, 

I have table users;

id  name  bin
--------------
 1   xx   9    

dec(1) & dec(9) = dec(1)  
bin(0001) & bin(1001) = bin(0001) 

This query is bad. 

SELECT name FROM users WHERE id_user=1 AND (bin & 1) 

This query return 
"Warning: PostgreSQL query failed: ERROR: right- hand side of AND is
type 'integer', not 'boolean' in"


Wow I write corect this query ? 

Thanks. 
 

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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Using & - operator
@ 2003-06-02 14:31  Dmitry Tkach <dmitry@openratings.com>
  parent: Rado Petrik <r.p@szm.sk>
  0 siblings, 0 replies; 2+ messages in thread

From: Dmitry Tkach @ 2003-06-02 14:31 UTC (permalink / raw)
  To: Rado Petrik <r.p@szm.sk>; +Cc: pgsql-sql

Rado Petrik wrote:

>Hi, 
>
>I have table users;
>
>id  name  bin
>--------------
> 1   xx   9    
>
>dec(1) & dec(9) = dec(1)  
>bin(0001) & bin(1001) = bin(0001) 
>
>This query is bad. 
>
>SELECT name FROM users WHERE id_user=1 AND (bin & 1) 
>
>This query return 
>"Warning: PostgreSQL query failed: ERROR: right- hand side of AND is
>type 'integer', not 'boolean' in"
>  
>
I think, you want:

... AND (bin & 1) = 1

just bin&1 returns an *integer*, and you need a *boolean* expression for 
your criteria.

I hope, it helps...

Dima

>Wow I write corect this query ? 
>
>Thanks. 
> 
>
>  
>





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-06-02 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-06-02 13:34 Using & - operator Rado Petrik <r.p@szm.sk>
2003-06-02 14:31 ` Dmitry Tkach <dmitry@openratings.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox