11

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

Tomalak
340k68 gold badges547 silver badges635 bronze badges
asked Jul 30, 2009 at 9:38

1 Answer 1

31

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;
answered Jul 30, 2009 at 9:42
Sign up to request clarification or add additional context in comments.

1 Comment

Just in case the (signed) literal is negative, comparing <> 0 might be a safer bet.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.