[nflug] really dumb SQL question

pirrone at localnet.com pirrone at localnet.com
Fri Dec 16 13:57:07 EST 2005



  Eric,

  SELECT * from ip_whatever ORDER BY
substring_index(ip_address,'.',-3) ASC;

  or

  In PHP the string function you are looking for is
explode('.',ip_address) which will break the value at its periods and
place the results in an array ip[0] to ip[3] for example.

  Frank

  Quoting Eric Benoit <ebenoit at hopevale.com>:

> I know this is slightly off the topic of this list,
>
> but I know there are some programmers out there ;)
>
> I have a column labled ip address, it is varchar, oddly enough I 
> input ...ip addresses in it. ha ha ha
>
> Here's my question:
>
> When I query the column and do an "order by ip_address ASC" the 
> records won't ascend the way I want ex: 192.0.0.20, 192.0.0.112 
and
> so on
>
> instead they ascend this way: 192.0.0.112, 192.0.0.20
>
> I am guessing this is because ASC doesn't like the periods?
>
> A finger pointed in some general direction would be great.
>
> Thanks,
> Eric
> _______________________________________________
> nflug mailing list
> nflug at nflug.org
> http://www.nflug.org/mailman/listinfo/nflug[1]
>


Links:
------
[1] 
/horde/services/go.php?url=http%3A%2F%2Fwww.nflug.org%2Fmailman%2Flistinfo%2Fnflug

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.nflug.org/pipermail/nflug/attachments/20070525/3ec30858/attachment.html
-------------- next part --------------
_______________________________________________
nflug mailing list
nflug at nflug.org
http://www.nflug.org/mailman/listinfo/nflug


More information about the nflug mailing list