我的billing
表中有两列:
cost_per_month
,VARCHAR
additional_cost
,DOUBLE
当我:
SELECT CONCAT_WS("", "$", FORMAT(db.billing.cost_per_month, 2)) AS "Monthly Cost",
CONCAT_WS("", "$", FORMAT(db.billing.additional_cost, 2)) AS "Additional Cost",
CONCAT_WS("", "$", FORMAT(CAST(db.billing.cost_per_month AS DECIMAL(60, 2)) + db.billing.additional_cost, 2)) AS "Total Cost"
FROM db.billing;
我明白了:
Monthly Cost Additional Cost Total Cost
$1,000.00 $ $
$0.00 $400.00 $400.00
$250.00 $250.00 $
而不是:
Monthly Cost Additional Cost Total Cost
$1,000.00 $0.00 $1,000.00
$0.00 $400.00 $400.00
$250.00 $250.00 $500.00
我试过了:
CAST(db.billing.cost_per_month AS SIGNED)
CAST(db.billing.cost_per_month AS UNSIGNED)
FORMAT()
和CONCAT_WS()
函数SUM()
一堆不同的方式答案 0 :(得分:2)
问题是由于行中没有 $file_name = $HTTP_POST_FILES['ufile']['name'];
//extension
$exx = pathinfo($file_name, PATHINFO_EXTENSION);
$random_digit=rand(0000,9999); //generating a unique number
$koubiac= strtotime("now"); //current time
$dirPath = '../'; //directorypath
$new_file_name=$random_digit.".".$exx; //filename is now a random number
$uploaddirectory = $dirPath.$random_digit.$koubiac; //upload directory is the path slash random digit concatenated with current time
mkdir($random_digit, 0755, true); //making directory
$path= $random_digit.'/'.$new_file_name; //path of file to save in MySQL DB table and for copying of file.
copy($HTTP_POST_FILES['ufile']['tmp_name'], $path); //copy to path
或NULL
时存在的cost_per_month
值。
解决方法是使用additional_cost
代替COALESCE()
。
在你的情况下:
CAST()