List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:October 14 2004 4:42am
Subject:Re: IP address to searchable number
View as plain text  
In the last episode (Oct 13), Scott Haneda said:
> 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?

INTEGER UNSIGNED.  Use inet_ntoa() and inet_aton() if the language
you're using to insert/query can't convert ip addresses itself.

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

-- 
	Dan Nelson
	dnelson@stripped
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