title: Copy value from other table on insert trigger, postgres
body: <p>I'm quite new to PostgreSQL and have spend too much time already to try to find an example to adapt for what i want to do. So I hope I can get some help here</p>
  
  <p>I have 2 tables, call them person and address</p>
  
  <p>I want to create a trigger that copy street and house_nr from table Address when I insert a new value for person_id in the first table where person_id = oid</p>
  
  <blockquote>
    <p>Table person<br>
    person_id<br>
    street<br>
    house_nr<br>
    other_attributes </p>
    
    <p>Table Address<br>
    oid<br>
    street<br>
    house_nr<br>
    other_attributes</p>
  </blockquote>
  
  <p>Something like this</p>
  
  <pre><code>INSERT INTO person
  set person.street = address.street,
      person.house_nr = address.house_nr
  FROM address
  WHERE person_id = oid
  </code></pre>
  
  <p>Hope someone will have time to help
  cheers</p>