Re: Using & - operator

From: Dmitry Tkach <dmitry(at)openratings(dot)com>
To: Rado Petrik <r(dot)p(at)szm(dot)sk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Using & - operator
Date: 2003-06-02 14:31:33
Message-ID: 3EDB5FC5.7070809@openratings.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.
>
>
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Samuel Tardieu 2003-06-02 15:47:35 Maintaining a counter up-to-date
Previous Message Dmitry Tkach 2003-06-02 14:28:16 Re: SQL problem: bank account