SkilletZA Posted September 4, 2013 Share Posted September 4, 2013 Hi all Noob here! I am busy writing a web app that posts fuel usage data into a MySQL DB. Some records get added into the DB on the day that the vehicle leave the site. This will include the 'OpenKM' field. On the return of the vehicle the 'CloseKM' gets updated (added) into the record. I would like to have 'Consump' field to contain (CloseKM-OpenKM)/(MillDiesel+OutDiesel) I am trying to figure out SQL Triggers, is that what I need to use to have this working? Any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/281846-help-needed-to-add-a-calculation-field-on-mysql/ Share on other sites More sharing options...
AbraCadaver Posted September 4, 2013 Share Posted September 4, 2013 Calculate 'Consump' when you need to use it, don't store it. You shouldn't be storing a result that is calculated from data that is already being stored. Link to comment https://forums.phpfreaks.com/topic/281846-help-needed-to-add-a-calculation-field-on-mysql/#findComment-1448118 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.