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
  #11  
Old   
relecom
 
Posts: n/a

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






^^^ wouldn't that only work if the ip addresses were entered into the database in the correct order? and I can't change the structure of the database.

thanks for the help,. Mark

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

Default Re: Sorting ip address for dynamic table - 10-16-2007 , 03:04 PM






How can you be wanting to sort someone elses database?


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

Default Re: Sorting ip address for dynamic table - 10-16-2007 , 03:05 PM



How do these "IP Addresses" get in the database?

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

Default Re: Sorting ip address for dynamic table - 10-16-2007 , 03:06 PM



it's an existing database, I just can't change the structure at all.

Mark

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

Default Re: Sorting ip address for dynamic table - 10-16-2007 , 03:09 PM



You didn't answer my second question.
How do they get in the database?

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

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



they are manually entered in.

Mark

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

Default Re: Sorting ip address for dynamic table - 10-16-2007 , 03:20 PM



Try this:

SELECT [radio_ip] FROM [sc_survey]
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)


Otherwise add a field called sortorder.


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

Default Re: Sorting ip address for dynamic table - 10-16-2007 , 04:09 PM



..oO(relecom)

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

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?
Not really, since I haven't done it before myself. It was just an idea,
since the algorithm to convert an IP to an integer is quite simple. It
should be possible to implement that with pure SQL or maybe in a stored
procedure.

Quote:
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)
Also looks good and correct from my understanding, but I'm not familiar
with Access or MS SQL Server.

Quote:
but it yields an error.
It always helps to not just say that there was an error, but to post the
actual and complete error message ...

Micha


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

Default Re: Sorting ip address for dynamic table - 10-16-2007 , 04:15 PM



What is the error?


"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
  #20  
Old   
bregent
 
Posts: n/a

Default Re: Sorting ip address for dynamic table - 10-16-2007 , 04:21 PM



Quote:
Try this:

SELECT [radio_ip] FROM [sc_survey]
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)
He is using MS Access. PARSENAME() is t-sql. You will need to use different
method to parse the ip.



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.