Jump to content

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/100462-decimals-in-enums-mysqlphp/
Share on other sites

If you're dealing with money where the calculations need to be penny perfect, then use NUMERIC. And if you want to specify a DEFAULT field value, then give your table a default column value.

"ENUM", i mean ??? were you thinking... ;)

ALTER TABLE <table name here> MODIFY COLUMN cast_num NUMERIC(6,2) NOT NULL DEFAULT 6.25

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.