title: copy data from one table to another using foreign key
body: <p>i am facing a problem regarding sql query.</p>
  
  <p>i have a table structure</p>
  
  <h2>TABLE_A</h2>
  
  <pre><code>A_id : 10,20,30,40 
  A_name: a,b,c,d  
  B_id: null,null,null,null
  </code></pre>
  
  <h2>TABLE_B</h2>
  
  <pre><code>B_id: 1,2,3,4  
  B_name:n1,n2,n3,n4 
  A_id: 10,20,30
  </code></pre>
  
  <p>Now <strong>I need to copy the B_id from TABLE_A to B_id of TABLE_B where A_id of TABLE_A is same as A_id of TABLE_B</strong></p>
  
  <p>the table will then look like</p>
  
  <h2>TABLE_A</h2>
  
  <pre><code>A_id : 10,20,30,40  
  A_name: a,b,c,d   
  B_id: 1,2,3,null
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>UPDATE TABLE_A 
  SET B_id = a.B_id
  from TABLE_A a 
  WHERE TABLE_A.A_id = a.A_id
  </code></pre>
  
  <p>but its not working and the error is <code>SQLCODE=-104, SQLSTATE=42601</code></p>