> Hate to interrupt your flame war, and I apologize for not being precise in > my meaning first try... You don't need any bitwise anything to compare two > bitmasks-hiding-in-integers, just check for equality. > > Instead of "select * from coloursample where colour & 10 = 10;" just try > "select * from coloursample where colour = 10;". Which works for that example. But please consider the more realistic one I also posted. The stored value is 21205 (I think... it was all a long time ago). I probe that with 4098. I do NOT want that returned, because the '2' bit is not set in the 21205 value. So select * from table where 21205=4098 won't cut it, will it? > If you want to probe for two values, that MUST be in there, and WITHOUT > anything else, bitwise OR them together as the probe value and use plain old > equals there too. You only need the bitwise AND stuff for checking for a > value that MUST be in there, regardless of whether or not other values are > in there as well. A Bitwise OR? Ah ha: I think that might be the key: ims=# select 21205 | 4098; ?column? ---------- 21207 (1 row) So again, what exactly am I supposed to test for here? I mean, select * from table where 21205 | 4098 = 21205 would do it, I suppose, because that would correctly reject the row. But so would select * from table where 21205 | 4098 = 4098. However, if I stumble on a bit further, I do manage this: ims=# select 21205 | 4097; ?column? ---------- 21205 (1 row) ...so select * from table where 21205 | 4097 = 21205 would correctly grab that record. So I'm assuming you mean the 'stored value' should be on both sides of the equals test. If so, that would indeed seem to be the ultimate answer to the question (though I wouldn't myself call it a 'plain old equals' :-) ) > Hope I was clearer this time. Originally I just fired off a quickie email to > get you past your coder's block. I do indeed think the magic of "BIT OR" is the missing ingredient I was looking for, and I very much appreciate your help leading me to it. My apologies for being too dense to spot what you were talking about before. Regards HJR -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general