Jump to content

Calculcation Based on MySQL Field - Newbie


chrison600

Recommended Posts

Hi all,

 

I would like to perform a simple multiplication operation against a field stored in a MySQL database. I need the results returned to a particular field in a table other than that which contains the multiplied field... That\'s as clear as mud...

 

A function that represents what I would like to do would be something like:

 

.02x = y

 

Where x is a PRICE field and y is a FEE field.

 

In other words, I want to charge a FEE that is 2% of the PRICE.

 

The PRICE is stored in the \'PRICE\' field of the \'g_class\' table.

 

The FEE is stored in the \'CHARGE\' field of the \'g_c_price_inc\' table.

 

The \'CHARGE\' field is a DOUBLE (16,2) type.

 

I can manipulate the \'CHARGE\' field directly, but I would like to stay away from changing the field type. I\'m not sure #1) if I can enter a formula into the \'CHARGE\' field without changing the field attributes, and #2) what the heck the formula should look like.

 

Can anyone help?

 

Thanks,

 

Chris

Link to comment
https://forums.phpfreaks.com/topic/550-calculcation-based-on-mysql-field-newbie/
Share on other sites

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.