title: How to create trigger to take value from another table depends of value from first table
body: <p>I'm lost with triggers in SQL</p>
  <p>Have one main table with all data, second table is only for support of first table. I need a trigger to get value from second table depends of value from first table.</p>
  <p><code>first_table</code></p>
  <pre><code> id | name | surname | age | category |
   --------------------------------------
   1  | John | Duck    | 30  |          |
  </code></pre>
  <p><code>second_table</code></p>
  <pre><code>id | age | category |
  ---------------------
  1  | 30  | adult    |
  2  | 12  | kid      |
  </code></pre>
  <p>Trigger will autofill column <code>category</code> from second table to first table and use age.</p>
  <p>I'm trying to add a trigger to the first table:</p>
  <pre><code>CREATE TRIGGER addCategory
  AFTER UPDATE ON first_table FOR EACH ROW
  BEGIN 
      DECLARE age int;
      SELECT category INTO table_one FROM table_two WHERE category = category;
      UPDATE table_one set category = NEW.category WHERE age = age;
  END 
  </code></pre>
  <p>Any tips?</p>
  <p>result:</p>
  <p><code>first_table</code></p>
  <pre><code> id | name | surname | age | category |
   --------------------------------------
   1  | John | Duck    | 30  |  adult   |  &lt;- value from second_table
  </code></pre>