dtempleton
MIS
Is it possible to link each bit in a binary field to a lookup table? Just curious.
Thanks,
Dave
Thanks,
Dave
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
create table lookup ( bitval int, value varchar(10) )
insert into lookup values ( 1, 'Bit 0')
insert into lookup values ( 2, 'Bit 1')
insert into lookup values ( 4, 'Bit 2')
insert into lookup values ( 8, 'Bit 3')
insert into lookup values (16, 'Bit 4')
create table blah ( foo varchar (10), bitmask binary(1) )
insert into blah values ( 'Row 1', 27 )
insert into blah values ( 'Row 2', 4 )
select A.foo, B.value
from blah A
inner join lookup B on A.bitmask & B.bitval <> 0