title: Calculations in php or mysql data
body: <p>I have come across a few questions on the same lines but none exactly the same.</p>
  
  <p>Which one is better, performing some basic calculations in PHP after getting results from MySql (by joining a few tables) or physically having another column in MySql which stores the total while inserting a new row and then retrieving it.</p>
  
  <p>E.g: A product sold:</p>
  
  <pre><code>Item         Price       Quantity      Discount
  Item 1        55           100           10%
  </code></pre>
  
  <p>The above is a sales table, the price column is joint from the items table. Based on the above question either we can use PHP to fetch results, perform <code>Price X Quantity X 0.10</code> or we our table can look like the following:</p>
  
  <pre><code>Item         Price       Quantity      Discount   Amount
  Item 1        55           100           10%        4950
  </code></pre>
  
  <p>Now which is the better way of doing such a simple task?</p>
  
  <p>Similar Question:
  <a href="https://stackoverflow.com/questions/6449072/doing-calculations-in-mysql-vs-php">Doing Calculations in MySql vs PHP</a></p>