SQL Syntax - like FIELD and BITPATTERN = BITPATTERN?

Поиск
Список
Период
Сортировка
Искать

SQL Syntax - like FIELD and BITPATTERN = BITPATTERN?

От:
Ozz Nixon <ozznixon@gmail.com>
Дата:
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.

Re: [SOLVED] SQL Syntax - like FIELD and BITPATTERN = BITPATTERN?

От:
Ozz Nixon <ozznixon@gmail.com>
Дата:
Figured it out:

./sql -S=10.1.10.232
PostgreSQL v8.x Compatible SQL Command Line Tool by 3F, LLC (www.3flabs.com 
)

SQL> select * from bffcomwiki where flags & 8 != 0;
pagename
= 
= 
= 
= 
= 
= 
========================================================================
Welcome

1 records found in 3.00 ms.

SQL>


On Mar 2, 2010, at 8:30 PM, Ozz Nixon wrote:

> 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.

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

От:
"Harvey, Allan AC" <HarveyA@OneSteel.com>
Дата:
> 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.
FAQ