Discussion: bitwise logic
Afficher un message
Vieux 24/08/2007, 20h24   #1
Wagner, Chris
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut bitwise logic

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@ae.ge.com
  Réponse avec citation
 
Page generated in 0,05155 seconds with 9 queries