I have a bit column (for example, ‘Column’).
How can I compare the value of this column to just any number?
SELECT * FROM TABLE WHERE 'Column' = 5
After executing the above query, I get an error message: the operator does not exist: bit = integer
I have a bit column (for example, ‘Column’).
How can I compare the value of this column to just any number?
SELECT * FROM TABLE WHERE 'Column' = 5
After executing the above query, I get an error message: the operator does not exist: bit = integer
2
Answers
When comparing a bit field to a number in PostgreSQL, you should use the bit literal syntax. You can alter your query as follows to compare the value 5 to a bit column named "Column":
This query will produce a list of the rows where the ‘Column’ field’s bit representation is 5.
Hope it works 🙂
You can convert the value to compre to bit
fiddle