Re: SQL Syntax - like FIELD and BITPATTERN = BITPATTERN?

From: "Harvey, Allan AC" <HarveyA(at)OneSteel(dot)com>
To: "Ozz Nixon" <ozznixon(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL Syntax - like FIELD and BITPATTERN = BITPATTERN?
Date: 2010-03-03 03:59:12
Message-ID: E97A5BB7699CAD48BE2711E7124711650601ADDA@ntlmsg03.onesteel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I do not know how to really describe this...
>
> In pascal I would do
>
> If (AField and Flag3)=Flag3 then ...
>
> Checking to see if AField contains the BIT(s) FLAG3 is set to... is
> there a way to do this in a SELECT statement -- select * from ATable
> where AField and 0x0004=0x0004
>
> ?
>
> Thanks,
> O.
>
perhaps select * from ATable where AField::bit(16) & B'000000000100' = B'0000000000000100';

Allan

The material contained in this email may be confidential, privileged or copyrighted. If you are not the intended recipient, use, disclosure or copying of this information is prohibited. If you have received this document in error, please advise the sender and delete the document. Neither OneSteel nor the sender accept responsibility for any viruses contained in this email or any attachments.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2010-03-03 04:07:30 Re: Trigger help - updates to column data with null values
Previous Message Bruce Momjian 2010-03-03 03:34:30 Re: [GENERAL] to_timestamp() and quarters