pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Mike Rylander <miker@purplefrog.com>
Cc: pgsql-sql@postgresql.org, Mats Sjöberg <mats.sjoberg@cybernetics.se>
Subject: Re: How do i extract a certain bit from a bigint column
Date: Wed, 12 May 2004 13:16:20 -0500
Message-ID: <20040512181620.GB4372@wolff.to> (raw)
In-Reply-To: <200405120817.39593.miker@purplefrog.com>
References: <A40C30932F52C4409B89ED049CCA06B13BA41D@srvex01.hk.cybernetics.se>
	<200405120817.39593.miker@purplefrog.com>

On Wed, May 12, 2004 at 08:17:39 -0400,
  Mike Rylander <miker@purplefrog.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;



view thread (4+ messages)

Message-ID: <20040512181620.GB4372@wolff.to>
Permalink:  ../20040512181620.GB4372@wolff.to/
Also on:    postgresql.org/message-id/20040512181620.GB4372@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, miker@purplefrog.com, mats.sjoberg@cybernetics.se
  Subject: Re: How do i extract a certain bit from a bigint column
  In-Reply-To: <20040512181620.GB4372@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox