Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group