SkilletZA Posted September 4, 2013 Share Posted September 4, 2013 (edited) 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. Edited September 4, 2013 by SkilletZA Quote Link to comment Share on other sites More sharing options...
Solution AbraCadaver Posted September 4, 2013 Solution 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.