title: UPDATE statement with multiple joins to main table in PostgreSQL
body: <p>I'm doing conversation from mysql to postgres.</p>
  
  <p>I try to update table EUTMPDFHDT T with join table EUTMPDFH T1 and EUTMPTBLDT T2.</p>
  
  <p>Here is code what I use in mysql.</p>
  
  <pre><code>UPDATE EUTMPDFHDT
  SET NWCOLID=T2.NWCOLID
  FROM EUTMPDFHDT T
  INNER JOIN EUTMPDFH T1 ON T.DFHID = T1.DFHID AND T1.DFHTYP IN ('D','U','S','P','B')
  INNER JOIN EUTMPTBLDT T2 ON T.COLID = T2.COLID
  </code></pre>
  
  <p>In postgres I did try to follow this <a href="https://stackoverflow.com/questions/32386246/update-statement-with-multiple-joins-in-postgresql">UPDATE statement with multiple joins in PostgreSQL</a></p>
  
  <p>But to no avail I cannot solve it because the update statement is not same.</p>
  
  <p>Here what have I done in postgres:</p>
  
  <pre><code>UPDATE EUTMPDFHDT AS T
  SET NWCOLID=T2.NWCOLID
  FROM 
  EUTMPDFH T1
  JOIN EUTMPTBLDT T2 ON T.COLID = T2.COLID
  WHERE T.DFHID = T1.DFHID AND T1.DFHTYP IN ('D','U','S','P','B');
  </code></pre>
  
  <p>Here is the error that I hit</p>
  
  <pre><code>ERROR:  invalid reference to FROM-clause entry for table "t"
  LINE 5:  JOIN EUTMPTBLDT T2 ON T.COLID = T2.COLID
                                 ^
  HINT:  There is an entry for table "t", but it cannot be referenced from this part of the query.
  QUERY:  UPDATE EUTMPDFHDT AS T
      SET NWCOLID=T2.NWCOLID
      FROM 
      EUTMPDFH T1
      JOIN EUTMPTBLDT T2 ON T.COLID = T2.COLID
      WHERE T.DFHID = T1.DFHID AND T1.DFHTYP IN ('D','U','S','P','B')
  </code></pre>