Re: How do i extract a certain bit from a bigint column

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Mike Rylander <miker(at)purplefrog(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org, Mats Sjöberg <mats(dot)sjoberg(at)cybernetics(dot)se>
Subject: Re: How do i extract a certain bit from a bigint column
Date: 2004-05-12 18:16:20
Message-ID: 20040512181620.GB4372@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, May 12, 2004 at 08:17:39 -0400,
Mike Rylander <miker(at)purplefrog(dot)com> wrote:
>
> The easiest way is to test for a bit using bitwise and:
>
> SELECT * FROM table WHERE (status & 2::BIGINT) <> 0 AND (status & 8::BIGINT) =
> 0;

The following will probably be a bit faster:
SELECT * FROM table WHERE (status & 10::BIGINT) = 8;

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jie Liang 2004-05-12 21:59:38 Re: [SQL] \set
Previous Message Theodore Petrosky 2004-05-12 17:57:50 where is this problem (trigger)