Source language: Translate to:

Sorting numbers

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

Sorting numbers

Postby smartmedia » Sat Feb 23, 2008 10:00 am

Hi...

I try to sort a field contains only numbers.
The result i get is:

1
10
11
12
13
14
15
16
17
18
19
20
3
4
5
6
7
8
9

Any ideas to make it work like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby Alex » Sat Feb 23, 2008 11:44 am

Hi,

I had the same problem, so, may be you need to try :

01
02
03

or what I did :

1
2
3
Z10
Z20
Z30


Best Regards


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

Postby Gaev » Sat Feb 23, 2008 12:40 pm

smartmedia:

I am guessing that even though you populate this field with numbers only, you have defined this field as a non-numeric field e.g. string or memo ... best option is to define this field as numeric ... but if you have some other reason to keep it non-numeric ... you might try and specify your sort field as ...
LPAD(str,len,padstr)
... according to documentation for mySQL here ... http://dev.mysql.com/doc/refman/4.1/en/ ... _substring ...
Returns the string str, left-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters.
... your values for len would be the length of the non-numeric field ... or the largest number of digits you expect to have in this field e.g. 9999 would mean len=4
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 2 guests

cron