这是查询
CASE SF.value
WHEN '' THEN '9999999999'
WHEN 'N/A' THEN '99999999'
WHEN 'POA' THEN '999999999'
WHEN 'Free' THEN -1
ELSE IF(SF.value IS NULL,'9999999999',CAST(SF.value as DECIMAL))
END as priceval,
///End Query
我在DB中有价值
value(varchar)
4
4.5
4.3
6.6
从DB获取后
PRINTING:
var_dump($data);
Output
---------
string(1) "4"
string(1) "5"
string(1) "5"
string(1) "7"
我需要按照以下顺序获取值BY整数或Float或Decimal但按顺序依次为
string(1) "4"
string(3) "4.3"
string(3) "4.5"
string(3) "6.6"
(OR)
int(1) "4"
int(3) "4.3"
int(3) "4.5"
int(3) "6.6"
答案 0 :(得分:1)
您使用DECIMAL
而未指定精度,请尝试CAST(SF.value AS DECIMAL(10,1))