OK so... Next problem...

I was thinking of storing the IPs in my Database for several reasons,
also I export myMysql data into a local MsSQL database once per day, so the column type would have to be compatible.

I was going to use CHAR(15) but there must be some more efficient way...

Any suggestions anyone?

    In addition to this, if I want to

    SORT BY `ipaddress`
    

    in CHAR column would simply sort alphabetically, meaning 1, 100, 30, 325 when I need it to be 1, 30, 100, 325.

    If that makes any sense.

      Unlike, for example, PostgreSQL, MySQL doesn't have an "inet" datatype, nor does it have a mechanism for defining custom datatypes.

      Since an IPv4 address can fit in an unsigned long (via [man]ip2long[/man]) it could be stored that way and it would sort as expected.

        Write a Reply...