title: Update Table Based Off Temporary Table
body: <p>In a postrgres system, I have created a temporary table that holds a foreign key value to another table. I am hoping to update another table with information from that temporary table based on the foreign key value in the table I want to update.</p>
  
  <p>My thought was to use an update query such as:</p>
  
  <p><code>update  playerdata set "slotID"=temp1."gameID" from temp1 where playerdata."PlayerID"=playerdata."PlayerID";</code></p>
  
  <p>However when I do this update, I get the same gameID for every slotID in the table when they should be different based off of playerID. </p>
  
  <p>For example if temp holds:</p>
  
  <pre><code>playerid gameID
  1         10
  2         11
  </code></pre>
  
  <p>the result of the player data table update is:</p>
  
  <pre><code>playerid     slotID
  1             10
  2             10
  </code></pre>
  
  <p>and I want the result to be:</p>
  
  <pre><code>playerid     slotID
  1             10
  2             11
  </code></pre>
  
  <p>I have also worked with a join statement with the temporary table and it works as expected, the gameID's are with their corresponding playerID. 
  <code>select w."PlayerID", t."gameID" from playerdata as w, temp1 as t where t."PlayerID" = w."PlayerID";</code></p>
  
  <p>Is there a way to update the player data table's slotid based off the corresponding temporary playerID and gameID?</p>