Skip to main content
Harm_Millaard
Inspiring
November 3, 2012
Question

What is wrong with mySQL query?

  • November 3, 2012
  • 1 reply
  • 1974 views

My query is:

mysql_select_db($database_mysql, $mysql);

$query_Recordset1 = 'SELECT *, FORMAT(`RPI`,2) As RPI,`CPU`*`Cores` As Phys_Cores, `OS_disks`+`Project_disks`+`Output_disks` as Disks, FORMAT(`Gain`,1) As Gain FROM `Personal_data`,`Benchmark_results` WHERE Personal_data.Ref_ID = Benchmark_results.Ref_ID '.$conditions.' ORDER BY Total, RPI ASC' ;

Notice the 2 decimals in the Format(`RPI`,2) statement, but I get:

So how do I get this shown as 1.00 instead of 1?

For the site in question, look here: http://ppbm5.com/DB-PPBM5-2.php

This topic has been closed for replies.

1 reply

Rob Hecker2
Legend
November 3, 2012

If in your table structure you define the field as TYPE decimal (7,2) then you won't need to try to define it in the query, it will always return a decimal of 7 digits in length, 2 to the right of the decimal, and your '1' will return as '1.00'.

Harm_Millaard
Inspiring
November 3, 2012

The field is now defined as FLOAT 6.2, but even after removing the higlighted FORMAT part of the query, it still shows up as 1 and not as 1.00 as I want it. Changing it to DECIMAL 6.2 still shows the same problem.

Rob Hecker2
Legend
November 3, 2012

Your argument should be

AS DECIMAL(7,2))