Calculated Fields... Question/Problem when updating..

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
parkin
Forum Commoner
Posts: 25
Joined: Wed Jul 23, 2003 3:18 am

Calculated Fields... Question/Problem when updating..

Post by parkin »

Hi..
I was wondering how do you update a calculated field in mysql? Using mysql? Are there any functions that could help you? Or do I have to create one?

Code: Select all

eg:
field 1 value: 10
field 2 value: 5
field 3 value: 15        (field 1 + field 2) 

then when i update and change field 2.. value: 8
I would like field 3's value to change..
So now field 3 value should be: 18
Can anyone help? :) I couldn't find much so far that could help me with this :(


any comments/ help.. is appreciated :wink:
Thanks alot! :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Personally I wouldn't bother with field 3, and do the calculations with the data when retrieving it for display, e.g.

Code: Select all

SELECT field1, field2, (field1 + field2) AS field3 FROM table
Mac
Post Reply