Sorting IP Address in a querie

  • Thread starter Thread starter Mark Miller via AccessMonster.com
  • Start date Start date
M

Mark Miller via AccessMonster.com

I trying to sort a feild Ip Address from xxx.xxx.xxx.1 to xxx.xxx.xxx.999.

Everything that I tried is not working, here is what I get.

xxx.xxx.xxx.1
xxx.xxx.xxx.123
xxx.xxx.xxx.2

How can I get it to look like this?

xxx.xxx.xxx.1
xxx.xxx.xxx.2
xxx.xxx.xxx.123
 
Hi Mark,

The problem you are encountering is an IP address is not a number (well not
a set of integers) your representation is a string, and a real ip address is
binary, if this data is in a table the best way I can think of is another
field that is the order and you will have to write some code to get the
order correct, the other way is to break the ip address down into it's
octets order by octet 1,2,3,4.
 
hi mark,

just make 4 different integer fields for all 4 classes of the IP.
by doing this u can apply simple order by statement to the query.


Himanshu

email : (e-mail address removed)
 
Back
Top