title: how can mysql update its own data?
body: <p>I got a mysql database which contains some trading orders(sell orders and buy orders). I want mysql to run my code written in javascript or php to 'trade' the orders. For example, if I have one sell order that sells 5 items at a certain price and one buy order that buys 3 items at the same price, I want the buy order to be filled and 2 items left for sell.</p>
  
  <p>I can write code in html pages, so it trades every time when someone opens my url. However, I want it to keep trading on the server side no matter whether a users observes or not.</p>
  
  <ol>
  <li>Can mysql calculates its own data automatically? How can I set up the trading process on mysql?</li>
  <li>If 1 is not possible, can I write some javascript or php code and let mysql run my code automatically? How can I set it up?</li>
  </ol>
  
  <p>Can anyone help please? Thanks!</p>