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
Bit strings are strings of 1's and 0's. They can be used to store or visualize bit masks. There are two SQL bit types: bit( n ) and bit varying( n ) , where n is a positive integer. bit type data must match the length n exactly; it is an error to attempt to store shorter or longer bit strings.
An operator is a reserved word or a character used primarily in a PostgreSQL statement's WHERE clause to perform operation(s), such as comparisons and arithmetic operations. Operators are used to specify conditions in a PostgreSQL statement and to serve as conjunctions for multiple conditions in a statement.
PostgreSQL INSERT Multiple Rows First, specify the name of the table that you want to insert data after the INSERT INTO keywords. Second, list the required columns or all columns of the table in parentheses that follow the table name. Third, supply a comma-separated list of rows after the VALUES keyword.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With