title: How to add two/multiple values together in mysql? How to write a function f(x)?
body: <p>I'm wondering how to add several values together. For example, I have a table1: </p>
  
  <pre><code>#|a1|a2|a3
  -|--|--|--
  1|##|##|##
  2|##|##|##
  3|##|##|##
  </code></pre>
  
  <p>and a table2:</p>
  
  <pre><code>#|b1|b2|b3
  -|--|--|--
  1|##|##|##
  2|##|##|##
  3|##|##|##
  </code></pre>
  
  <p>I want to get:</p>
  
  <pre><code>y = sum(a1) + b1(3)  -- Sum of a1 and the third element of b1.
  </code></pre>
  
  <p>Also, How can I do more complex functions like:</p>
  
  <pre><code>y = (a1(2) * 3 + b2(2) * a3(2)) / avg(b1)
  </code></pre>