Comparing bit in an integer field

Поиск
Список
Период
Сортировка
От Amitabh Kant
Тема Comparing bit in an integer field
Дата
Msg-id 84b68b3d0911160600q290abb16je573b6ff126bebaa@mail.gmail.com
обсуждение исходный текст
Ответы Re: Comparing bit in an integer field
Re: Comparing bit in an integer field
Список pgsql-general
Hello

I need to compare the bit values of a integer field in my table. For example, I have a table called "t1" with just one field "a1" having following values:

a1
==
0
12
8
0
1
10
7
19

I am trying to fetch all records where the 3rd binary bit is 1, which from the above example should be 12 (00001100) and 7 (00000111). If I convert the values to binary and store it as string, I can easily compare them using substr, but would rather like to retain the integer field. I have tried using the get_bit function, but it seems my understanding of the function is not correct.

I would appreciate any help in this regard.


Amitabh

В списке pgsql-general по дате отправления:

Предыдущее
От: "Eric Comeau"
Дата:
Сообщение: Re: Customize the install directory of the postgres DB
Следующее
От: Thom Brown
Дата:
Сообщение: Re: Comparing bit in an integer field