Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to read if a bit on position x is set.
So for instance I want to check if useragent = chrome

I try:
SQL
select UserAgent from bits where UserAgent &3 =4
I get nothing. How do I get just the chrome from bits table (00000111)?

00000001 = all
00000011 = opera
00000111 = chrome
00001111 = safari

create table bits(UserAgent binary)
insert into bits(userAgent) values (00000001)
insert into bits(userAgent) values (00000011)
insert into bits(userAgent) values (00000111)
insert into bits(userAgent) values (00001111)


Thanks,
Robert
Posted
Comments
PIEBALDconsult 13-Nov-13 23:47pm    
"UserAgent &3 =4" would never be true.

1 solution

Try this. I think there is logic issue with the way you are setting the bits. In my opinion thsi should be bit values

All =111
opera=001
chrome =010
safari=100


SQL
select UserAgent&4 from @bits
where UserAgent&4=4
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900