Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EF1394760E8 for ; Wed, 30 Oct 2002 17:00:54 -0500 (EST) Received: from mail.4dmatrix.com (mail.4dmatrix.com [208.248.151.248]) by postgresql.org (Postfix) with ESMTP id 614AF475E84 for ; Wed, 30 Oct 2002 17:00:54 -0500 (EST) Received: from joshdesk2 (sonicwall.4dmatrix.com [208.248.151.201] (may be forged)) by mail.4dmatrix.com (8.9.3/8.9.3) with SMTP id NAA16743; Wed, 30 Oct 2002 13:49:52 -0800 Message-ID: <008601c2805f$bacf9550$6e02a8c0@4dmatrix.com> From: "Josh Goldberg" To: "Ericson Smith" , References: <1035939687.26937.7.camel@linux> Subject: Re: Bit string manipulation in Postgresql Date: Wed, 30 Oct 2002 14:00:12 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/310 X-Sequence-Number: 6168 http://www.postgresql.org/idocs/index.php?functions-math.html is this what you're after? SELECT 1 WHERE B'1010' & B'0110' > B'0001'; returns 1 SELECT 1 WHERE B'1010' & B'0100' > B'0001'; returns null ----- Original Message ----- From: "Ericson Smith" To: Sent: Tuesday, October 29, 2002 5:01 PM Subject: [ADMIN] Bit string manipulation in Postgresql > Hi all, > > I'm trying to code a problem where a set of options can be expressed in > a data column like "10111011", a bit string. > > Each position is atomic and represents a certain setting within the set, > thus: "00100000" would return TRUE if OR'd with "10111011", since the > 3'rd position matches in both sets. > > While I could manually retrieve N records and iterate through them in > whatever programming language (or possibly a plpgsql function), is there > a way I could natively do this in a WHERE clause in my query? > > Looking through the idocs, I could not immediately find a way around > this issue. Any pointers to documentation (or perhaps another way to > implement this issue) would be very helpful. > > Regards > Ericson Smith > eric@did-it.com > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >