views:

33

answers:

1

I currently have a MySQL database with a table that has a field that is typed as a decimal.

Currently there are values that range from *.1 through *.9 but we now need to be able to handle the following:

I need to be able to add *.10 to this field and sort it accordingly.

In this use-case .10 DOES NOT equal .1!

I need to be able to use this value in Rails and output it appropriately.


Is there an easy way around this that I am just missing or should I just split it up as follows:

Split the one field into two:

2.1 -> 2 & 1

2.10 -> 2 & 10


Thanks in advance!

+2  A: 

You either need to split it into two fields or change it to a CHAR field of sufficient length (the two-fields option is probably better from a comparison point of view). A decimal field can't differentiate between 2.1 and 2.10 because they are the same number.

James McNellis