[nflug] really dumb SQL question

Justin Bennett Justin.Bennett at Dynabrade.com
Fri Dec 16 13:21:32 EST 2005


that's becasue It's a character field. It's looking at it as a string, 1 
comes before 2 so the 20 comes before 112. It doesn't look at those as 
numbers, but rather a string with a 1 in the same position as 2 in the 
corresponding position in the other row and 1 comes before 2.

it would be like

apple12
apple3

apple12 would come before apple3 becuase it's a string comparing each 
character against the corresponding character in the other rows.


You could store it as  a binary number


Justin Bennett
Network Administrator
Dynabrade, Inc.
8989 Sheridan Dr.
Clarence, NY 14031
 



On 12/16/2005 12:42 PM, Eric Benoit wrote:

> 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

_______________________________________________
nflug mailing list
nflug at nflug.org
http://www.nflug.org/mailman/listinfo/nflug



More information about the nflug mailing list