Hi!

>>>>> "Benjamin" == Benjamin Pflugmann <[EMAIL PROTECTED]> writes:

Benjamin> Hi.
Benjamin> IMHO your query should work. This looks like a bug to me. I can
Benjamin> confirm this on 3.23.46, but have no more current version available
Benjamin> for testing.

<cut>

>> I'm having a simple but annoying problem:
>> 
>> i want to round() the value of a column, but the number of digits is
>> depending on the value of another column. i found out, that this doesn't work:
>> 
>> create table testme (number double (5,4),digits tinyint(3));
>> insert into testme values (100.4235,3),(85.4,1);
>> select round(number,digits) from testme;
>> +----------------------+
>> | round(number,digits) |
>> +----------------------+
>> |             100.4240 |
>> |              85.4000 |
>> +----------------------+
>> 2 rows in set (0.08 sec)
>>
>> is there any way i could do this with *one* query? 
>> the only solution i see is to read the digits-column with a script and then
>> create a new query, but thats not possible in my case...

The problem here is a type problem.

All expressions in MySQL has a result type.  This is needed as all
entries in a column has to be of the same type.

The type of round(x,y) is double(max_double_digits,y) if y is a
constant and double(max_double_digits,4) if y isn't a constant.  (The
4 is just a chosen value, as we didn't think of any better value)

The reason for the results is that all numbers are always sent to the
client with the correct number of decimals (according to it's type).

Sorry, but there isn't any easy workaround for this.

Regards,
Monty

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to