postgresql - How to decode bit mask in sql -


for example 10 = 2+8 = 2^1 + 2^3

in query, how can select when want code contains 2^1 or 2^3?

you can try:

where (10 & (1 << 1) ) > 0 or  (10 & (1 << 3)) > 0 

or, single operator:

where 10 & ( (1 << 1) | (1 << 3) ) > 0 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -