Elitmiar
Elitmiar

Reputation: 36839

Bitwise operators in Postgres

I have a problem with using Bitwise operators in Postgres I get the following error message

ERROR:  argument of WHERE must be type boolean, not type integer

My query looks as below

SELECT DISTINCT number,name,contact,special FROM clients WHERE special & 2048;

Any help will be appreciated

Upvotes: 11

Views: 15249

Answers (1)

Tomalak
Tomalak

Reputation: 338228

You'll need to do a comparison:

SELECT DISTINCT number, ..., special FROM clients WHERE special & 2048 = 2048;

or

SELECT DISTINCT number, ..., special FROM clients WHERE special & 2048 > 0;

Upvotes: 31

Related Questions