select sum(product.price)
from name , product , type
where product.type_id = type.type_id
and product.name_id = name.name_id
and product.product_id = '9'
ดูใน ฐานข้อมูลค่าที่ออกมาเป็น 12.52
แต่เวลา echo ค่าที่ออกมาคือ 12 ต้องแก้ยังไงค่ะ ขอคำแนำนำ หน่อยค่ะ
อ้างถึงจาก: Nato_One ใน 18 มกราคม 2013, 10:55:57
select sum(product.price)
from name , product , type
where product.type_id = type.type_id
and product.name_id = name.name_id
and product.product_id = '9'
ดูใน ฐานข้อมูลค่าที่ออกมาเป็น 12.52
แต่เวลา echo ค่าที่ออกมาคือ 12 ต้องแก้ยังไงค่ะ ขอคำแนำนำ หน่อยค่ะ
ชนิดของข้อมูลที่เก็บใน DB คือชนิดแบบไหนครับ
DECIMAL( 12, 2 ) รึป่าว
อ้างถึงจาก: jkscript ใน 18 มกราคม 2013, 11:04:12
อ้างถึงจาก: Nato_One ใน 18 มกราคม 2013, 10:55:57
select sum(product.price)
from name , product , type
where product.type_id = type.type_id
and product.name_id = name.name_id
and product.product_id = '9'
ดูใน ฐานข้อมูลค่าที่ออกมาเป็น 12.52
แต่เวลา echo ค่าที่ออกมาคือ 12 ต้องแก้ยังไงค่ะ ขอคำแนำนำ หน่อยค่ะ
ชนิดของข้อมูลที่เก็บใน DB คือชนิดแบบไหนครับ
DECIMAL( 12, 2 ) รึป่าว
Type = double ค่ะ
echo ค่าออกธรรมดาค่ะ
copy code มาดูดีกว่า
ถ้าไม่ได้ไปแปลงค่าอะไร มัน ไม่น่าจะเปลี่ยนค่านะ
ลองเอา sql ไป run ใน DB ตรงๆดูด้วยครับ ว่าค่าเท่ากันจริงหรือเปล่า
ลอง
cast((sum(product.price*1.0)) as float) as sumone
อ้างถึงจาก: MapTwoZa ใน 18 มกราคม 2013, 12:14:29
ลอง
cast((sum(product.price*1.0)) as float) as sumone
ได้แล้วขอบคุณค่ะ
อ้างถึงจาก: MapTwoZa ใน 18 มกราคม 2013, 12:14:29
ลอง
cast((sum(product.price*1.0)) as float) as sumone
โดนตัดหน้าาาาาา :-[