1. The best way of IP address in Mysql

    After needing this for something at work I found this entry on a mysql list.

    http://lists.mysql.com/cluster/2784

    The best parts of which are that it’s best to store a INT(10) value - so you have to turn the IP in to an integer.

    Luckily Mysql has 2 functions to do this for you..

    INET_ATON() and INET_NTOA()

    For example.. 

    mysql> SELECT INET_ATON(‘192.168.0.2’);

    +—————————————+
    |         INET_ATON(‘192.168.0.2’) |
    +—————————————+
    |                             3232235522 |
    +—————————————+

    OR

    mysql> SELECT INET_NTOA(‘3232235522’);

    +————————————-+
    | INET_NTOA(‘3232235522’) |
    +————————————-+
    | 192.168.0.2             |
    +————————————-+

    Simple and easy!