title: PostgreSQL: insert from another table
body: <p>I'm trying to insert data to a table from another table and the tables have only one column in common. The problem is, that the TABLE1 has columns that won't accept null values so I can't leave them empty and I can't get them from the TABLE2.</p>
  
  <p>I have TABLE1:
  id, col_1 (not null), col_2(not null), col_3 (not null)</p>
  
  <p>and TABLE2:
  id, col_a, col_b, col_c</p>
  
  <p>so how could I insert id from TABLE2 to TABLE1 and fill the col_1-3 with hard coded strings like "data1", "data2", "data3"?</p>
  
  <pre><code>INSERT INTO TABLE1 (id) SELECT id FROM TABLE2 WHERE col_a = "something";
  </code></pre>
  
  <p>will result in:</p>
  
  <blockquote>
    <p>ERROR:  null value in column "col_1" violates not-null constraint</p>
  </blockquote>