Forum Moderators: coopster

Message Too Old, No Replies

A question of SORT

         

grandpa

12:00 pm on Jan 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've been looking into a minor little glitch in one my programs. I'm writing a transaction table for sales orders, and two of the fields are 'Number of Distrbutions' and 'Sales Order Distribution'. The Number of Distributions contains the total number of line items for an order, the Sales order Distribution is the number associated with any given line item.

You can probably already guess the problem I'm having with this. When I read the sales order out of the database, it will be read out of order, ie,

1
10
11
12
2
20
21
3
4
5

I understand using natsort will resolve this problem. But the problem lies in the database, not in the actual sorting. In other words, I'm not reading these lines from an array where I might apply natsort. So my question would be, how do I sort this out (pun intended) with the database (MySQL).

The first solution I've come up with is to make my field (SOD) a text field, default '00000', and superimpose the line item number. That should work... and would be easier than trying to populate an array and re-sort everything.

Is this the sort of thing (another pun intended) you've dealt with, and what was your solution?

gracias

mincklerstraat

12:46 pm on Jan 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You make sure that these fields aren't of the type varchar or text, and that they're of numeric types, like INT?

grandpa

12:52 pm on Jan 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ugh! They are varchar.

distno varchar(5) default NULL
distso varchar(5) default NULL

I changed them to INT and I like the results.

Thanks.