MySQL:IP 地址转换(在常见IP地址现数字之间相互转换)

mysql> select inet_aton('192.168.202.12');
+-----------------------------+
| inet_aton('192.168.202.12') |
+-----------------------------+
|                  3232287244 |
+-----------------------------+
1 row in set (0.00 sec)
 
2、IP由数据形式转换为点分形式
 
mysql> select inet_ntoa('3232287244');
+-------------------------+
| inet_ntoa('3232287244') |
+-------------------------+
| 192.168.202.12          |
+-------------------------+
1 row in set (0.08 sec)
 
  自己经常忘记这个函数的具体写法,呵呵~  给个记住此函数的小技巧,如下:
  inet_aton():可以理解为 i(p)net_a(ddress)ton(umeric)  分开来就是 
    ip 网络(net) 地址(address) 转换为 数字(numeric)
    i   net_          a              to       n                   
 
  反之!
 
  希望对你有帮助! O(∩_∩)O~
posted @ 2016-05-31 17:30  huababy  阅读(3430)  评论(0编辑  收藏  举报