HighDots Forums  

Sorting ip address for dynamic table

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Sorting ip address for dynamic table in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
relecom
 
Posts: n/a

Default Sorting ip address for dynamic table - 10-12-2007 , 05:06 PM






I am trying to sort an ip address coloumn, and it't working but not sorting
properly.

SQL:

SELECT radio_ip
FROM sc_survey
WHERE radio_ip LIKE MMColParam%
ORDER BY radio_ip ASC

as you cvan see it's sorting, but not in order

what is the proper format to sort ip addresses in actual order?

thanks, Mark


Reply With Quote
  #2  
Old   
east99
 
Posts: n/a

Default Re: Sorting ip address for dynamic table - 10-13-2007 , 03:07 PM






I know for a fact that I saw a link here to a javascript code that could do
what you need.
I can't remember the name though.

Cheers


"relecom" <webforumsuser (AT) macromedia (DOT) com> wrote

Quote:
I am trying to sort an ip address coloumn, and it't working but not sorting
properly.

SQL:

SELECT radio_ip
FROM sc_survey
WHERE radio_ip LIKE MMColParam%
ORDER BY radio_ip ASC

as you cvan see it's sorting, but not in order

what is the proper format to sort ip addresses in actual order?

thanks, Mark




Reply With Quote
  #3  
Old   
Michael Fesser
 
Posts: n/a

Default Re: Sorting ip address for dynamic table - 10-13-2007 , 03:53 PM



..oO(relecom)

Quote:
I am trying to sort an ip address coloumn, and it't working but not sorting
properly.

SQL:

SELECT radio_ip
FROM sc_survey
WHERE radio_ip LIKE MMColParam%
ORDER BY radio_ip ASC

as you cvan see it's sorting, but not in order

what is the proper format to sort ip addresses in actual order?
Just an idea:

You could store the IP addresses as 32bit integers instead of strings or
convert from string representation to integer before sorting.

You can find explanations and algorithms for doing that on Google, for
example

http://www.aboutmyip.com/AboutMyXApp/IP2Integer.jsp

Micha


Reply With Quote
  #4  
Old   
relecom
 
Posts: n/a

Default Re: Sorting ip address for dynamic table - 10-15-2007 , 12:00 PM



anyone else? I can't cdhange how the ip's are stored in the database, I only have control over the ASP side.

regards,

Reply With Quote
  #5  
Old   
Michael Fesser
 
Posts: n/a

Default Re: Sorting ip address for dynamic table - 10-15-2007 , 12:44 PM



..oO(relecom)

Quote:
anyone else? I can't cdhange how the ip's are stored in the database, I
only have control over the ASP side.
You could still do it in SQL and perform the IP <-> INT conversion when
fetching the results ...

Micha


Reply With Quote
  #6  
Old   
relecom
 
Posts: n/a

Default Re: Sorting ip address for dynamic table - 10-15-2007 , 02:47 PM



[q]Originally posted by: Newsgroup User
.oO(relecom)

Quote:
anyone else? I can't cdhange how the ip's are stored in the database, I
only have control over the ASP side.
You could still do it in SQL and perform the IP <-> INT conversion when
fetching the results ...

Micha
[/q]

can you elaborate on that?

I was told to use this code:

ORDER BY CAST(PARSENAME(Radio_ip, 4) AS INT),
CAST(PARSENAME(Radio_ip, 3) AS INT),
CAST(PARSENAME(Radio_ip, 2) AS INT),
CAST(PARSENAME(Radio_ip, 1) AS INT)


but it yields an error.

thanks guys, Mark





Reply With Quote
  #7  
Old   
bregent
 
Posts: n/a

Default Re: Sorting ip address for dynamic table - 10-15-2007 , 02:50 PM



What dbms are you using?

Reply With Quote
  #8  
Old   
relecom
 
Posts: n/a

Default Re: Sorting ip address for dynamic table - 10-15-2007 , 03:44 PM



a ms access database, coding with ASP vb.

mark

Reply With Quote
  #9  
Old   
east99
 
Posts: n/a

Default Re: Sorting ip address for dynamic table - 10-16-2007 , 02:37 PM



Very simple:

Add a field called "sortorder" a number field
Allow only 3 characters and sort using that.

SQL:

SELECT radio_ip
FROM sc_survey
WHERE radio_ip LIKE MMColParam%
ORDER BY sortorder ASC

OR

SELECT radio_ip
FROM sc_survey
WHERE radio_ip LIKE MMColParam%
ORDER BY sortorder DESC

Pick one. That solves all your issues.
Cheers




"relecom" <webforumsuser (AT) macromedia (DOT) com> wrote

Quote:
anyone?

Mark



Reply With Quote
  #10  
Old   
east99
 
Posts: n/a

Default Re: Sorting ip address for dynamic table - 10-16-2007 , 02:44 PM



Sorry didn't read your post properly but this is very, very simple:

Add a field called "sortorder" a number field
Allow only 3 characters and sort using that.

SQL:

SELECT radio_ip
FROM sc_survey
WHERE radio_ip LIKE MMColParam%
ORDER BY sortorder ASC

OR

SELECT radio_ip
FROM sc_survey
WHERE radio_ip LIKE MMColParam%
ORDER BY sortorder DESC

Pick one. That solves all your issues.
Cheers

[q]Originally posted by: relecom
I am trying to sort an ip address coloumn, and it't working but not sorting
properly.

SQL:

SELECT radio_ip
FROM sc_survey
WHERE radio_ip LIKE MMColParam%
ORDER BY radio_ip ASC

as you cvan see it's sorting, but not in order

what is the proper format to sort ip addresses in actual order?

thanks, Mark[/q]




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.