I think Gerald was suggesting you convert the IP's into integers and
then do bitwise stuff on them. I don't know of a way to do what you're
asking.
Baron
Wagner, Chris (GEAE, CBTS) wrote:
> Those functions concern dotted quad IP addresses, not packed binaries.
>
> Anybody know of some obscure MySQL functions to do bit logic on strings
> or get MySQL to recognize a char sequence as an integer?
>
> "Gerald L. Clark" wrote:
>> Wagner, Chris (GEAE, CBTS) wrote:
>>> 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.
>>>
>>>
>> Try INET_ATON() and INET_NTOA().
>>
>> --
>> Gerald L. Clark
>> Supplier Systems Corporation
>
--
Baron Schwartz
Xaprb LLC
http://www.xaprb.com/