List:General Discussion« Previous MessageNext Message »
From:Chris (GEAE, CBTS) Wagner Date:August 24 2007 7:24pm
Subject:bitwise logic
View as plain text  
Hi.  I've got IP addresses stored in the database as packed binaries.
i.e. binary(4).  I put them in there that way so that I could do bitwise
logic on them to do subnet searches.  e.g. ...WHERE `ip` & 'mask' =
'network'.  Only it turns out that as far as I can tell MySQL can't do
bit logic on strings, only integers.  I came up with an onerous SQL call
that eats the 4 bytes and makes an integer out of them but there's got
to be a better way.  The worst case is that I redo the database to have
all the IP's as integers.  

Anybody know of a way to make MySQL either do the bit logic on the
string or convert/cast the string as an integer?  Thanks.


-- 
Chris Wagner
CBTS
GE Aircraft Engines
Chris.Wagner@stripped
Thread
bitwise logicCBTS) GEAE24 Aug
  • Re: bitwise logicCBTS) GEAE28 Aug
    • Re: bitwise logicBaron Schwartz28 Aug
      • Re: bitwise logicJeremy Cole10 Sep