Re: IP Address Function?

2006-08-26 Thread nigel wood

Chris Knipe wrote:


Hi,

I need to make *allot* of queries from a application dealing with IP 
Addresses.  At the moment, I'm storing IP addresses as a VARCHAR(16).  
I would *like* to store them as Integers by converting the IP to it's 
numerical equivalent.  I believe this would also save a enormous 
amount of table space.


The problem is, I *must* do the conversion as part of my SQL Query.  
Either during the SELECT/UPDATE/INSERT, or via a Procedure... And I 
must obviously also be able to convert the Integer back into a IP 
address during queries


Is this at all possible???
mytable


MySQL has dotted IP string to integer (and vice versa)  conversion 
functions.  You'd use them in queries like:


insert into  mytable set IPaddress = funcName('192.168.191.34');
select funcName(IPaddress) as strIPaddress, IPaddress as intIPaddress 
from mytable;


I suspect you posted to the list before attempting to the functions in 
the online documentation so I'll  simply confirm they exist and leave 
you to: Do Your Own Research by Reading The Fine Manual.


Nigel Wood


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: IP Address Function?

2006-08-26 Thread Chris Knipe

RTFM! Let that be a good lesson for me now :)

INET_ATON() and INET_NTOA()  Brilliant!!!


Regards,
Chris.

- Original Message - 
From: Chris Knipe [EMAIL PROTECTED]

To: mysql@lists.mysql.com
Sent: Saturday, August 26, 2006 9:03 PM
Subject: IP Address Function?



Hi,

I need to make *allot* of queries from a application dealing with IP 
Addresses.  At the moment, I'm storing IP addresses as a VARCHAR(16).  I 
would *like* to store them as Integers by converting the IP to it's 
numerical equivalent.  I believe this would also save a enormous amount of 
table space.


The problem is, I *must* do the conversion as part of my SQL Query. 
Either during the SELECT/UPDATE/INSERT, or via a Procedure... And I must 
obviously also be able to convert the Integer back into a IP address 
during queries


Is this at all possible???

It's all explained very nicely at 
http://www.aboutmyip.com/AboutMyXApp/IP2Integer.jsp  But how to do this as 
part of a query... *frown*


Any help appreciated...


Regards,
Chris.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]