I am storing ips in a mysql 4.0.17 db as int. I am Converting them using a perl script with inet_aton to create a four-byte string.
My goal: Is to return the ip as a normal dotted ip for the user to see after a select statement is done via a php web page. The ip is entered in as a dotted ip on the web page. My db has on normal 100 millon rows a month and I'm trying to get away from storing Ips as varchar(15). My php page that does a select statment like so: $query = "select * from june04 where src = inet_aton('$src')"; Data is returned: 3232235521 But I want it returned like: 192.168.0.1 Can my select statement do that for me?? Or should I use php when the data is printed. I was hoping to do it with mysql since the db server as much more memory and cpu power... Thanks Ron Db info: mysql> create table june04 ( src int unsigned); Query OK, 0 rows affected (0.00 sec) mysql> insert into june04 values (inet_aton('192.168.0.1')); Query OK, 1 row affected (0.00 sec) mysql> select src from june04; +------------+ | src | +------------+ | 3232235521 | +------------+ 1 row in set (0.00 sec) mysql> select inet_ntoa( src ) from inet_test; +-----------------+ | inet_ntoa( src ) | +-----------------+ | 192.168.0.1 | +-----------------+ 1 row in set (0.00 sec)