title: UPDATE JOIN statement for DB2
body: <p>I am using DB2, and am a beginner in SQL. I have two tables here:</p>
  
  <p>Table1:</p>
  
  <pre><code>ID | PageID 
  ------------
  1  |   101  
  2  |   102
  3  |   103
  4  |   104
  </code></pre>
  
  <p>Table2:</p>
  
  <pre><code>ID | SRCID | PageID
  --------------------
  1  |  2    | 179
  2  |  3    | 103
  3  |  3    | 109
  </code></pre>
  
  <p>Table2 and Table1 have different number of records. Table2.SCRID corresponds to Table1.ID. 
  I would like to update the PageID in Table2 to follow what is stated in PageID of Table1, based on the SRCID.
  My end result of Table2 should be:</p>
  
  <pre><code>ID | SRCID | PageID
  --------------------
  1  |  2    | 102
  2  |  3    | 103
  3  |  3    | 103
  </code></pre>
  
  <p>How do I do this in SQL for DB2?</p>
  
  <p>I tried:</p>
  
  <pre><code>UPDATE table2
    SET PageID = (SELECT t1.PageID from table1 as t1 join table2 as t2
        WHERE t2.SCRID = t1.ID);
  </code></pre>
  
  <p>But the above doesn't work as I get:</p>
  
  <p>DB21034E  The command was processed as an SQL statement because it was not a
  valid Command Line Processor command.  During SQL processing it returned:
  SQL0811N  The result of a scalar fullselect, SELECT INTO statement, or VALUES
  INTO statement is more than one row.  SQLSTATE=21000</p>
  
  <p>The problem here is there is no unique column for me to join such that each column gets a unique result..or so it seems to me. Please help? :(</p>