Jump to content

[SOLVED] Decimals in Enums MySQL/PHP


anser316

Recommended Posts

Hi in a table i want just one number (6.25) that i want added to all rows. e.g.

 

ID  cust_num

1      6.25

2      6.25

3      6.25

 

I would like it as the default value if it is not inserted also.

I was thinking ENUM('6.25') NOT NULL

I have some issues though with this

Can I do sums with ENUM on php or mysql?

e.g. $row2[total_quantity]*$row[cust_num]

And if so do i need quotes as it will be like a float or decimal?

Link to comment
https://forums.phpfreaks.com/topic/100479-solved-decimals-in-enums-mysqlphp/
Share on other sites

ENUM really wouldn't be the best way to go. If you are wanting the value to be treated as a number, you need to have a numeric type on the column. I would recommend simply having a float type with a DEFAULT of 6.25. If you do that, then you just don't have to insert a value into that column at all, and you can run aggregate functions on it (such as SUM).

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.