List:General Discussion« Previous MessageNext Message »
From:Gary Richardson Date:October 14 2004 4:40am
Subject:Re: IP address to searchable number
View as plain text  
Hey,

It's really easy to do. Store the IP addresses as int's and use the
inet_aton and inet_ntoa functions:

http://dev.mysql.com/doc/mysql/en/Miscellaneous_functions.html#IDX1519

You can actually store them as strings and use the inet_* functions in
your between statements as well.

On Wed, 13 Oct 2004 21:33:32 -0700, Scott Haneda <lists@stripped> wrote:
> Given a IP range such as:
> 12.8.197.10 -> 12.8.197.100
> 
> I want to store those 2 values in a database, before I insert a new value, I
> would like to test for the new values existence.
> 
> Any idea what I should convert a IP address into in order to be able to
> operate on it with simple greater than, less than and equal to math?
> --
> --
> -------------------------------------------------------------
> Scott Haneda                                Tel: 415.898.2602
> <http://www.newgeo.com>                     Fax: 313.557.5052
> <scott@stripped>                          Novato, CA U.S.A.
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
> 
>
Thread
IP address to searchable numberScott Haneda14 Oct
  • Re: IP address to searchable numberGary Richardson14 Oct
  • Re: IP address to searchable numberDan Nelson14 Oct
  • Re: IP address to searchable numberJames Weisensee14 Oct
  • Re: IP address to searchable numberJigal van Hemert14 Oct