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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.