title: Insert many rows returning id and update that ids in another table
body: <p>I am working with PostgreSQL, My sql structure:</p>
  
  <pre><code>CREATE TEMP TABLE users (
      id_user serial,
      user_name varchar,
      id_user_description int
  );
  
  CREATE TEMP TABLE user_description  (
      id_user_description serial,
      age int
  );
  </code></pre>
  
  <p><code>users</code> table has some users:</p>
  
  <pre><code>INSERT INTO users (user_name)
  SELECT column1
  FROM (
      VALUES
      ('John'),
      ('Amanda')
  ) t;
  </code></pre>
  
  <p>I am trying to insert data to table <code>user_description</code> and I also need to update inserted row ids to table <code>users</code>. My query is this:</p>
  
  <pre><code>WITH inserted_user_description AS (
      INSERT INTO user_description (age)
      SELECT age
      FROM (
          SELECT users.id_user,
              t.column1 AS age,
              t.column2 AS user_name
          FROM (
              VALUES
              (21, 'John'),
              (28, 'Amanda')
          ) t
          INNER JOIN users ON users.user_name = t.column2
      ) tt
      RETURNING id_user_description, tt.id_user
  )
  UPDATE users SET id_user_description = t.id_user_description
  FROM (
      SELECT id_user_description, id_user
      FROM inserted_user_description 
  ) t
  WHERE users.id_user = t.id_user;
  </code></pre>
  
  <p>But I get error:</p>
  
  <blockquote>
    <p>ERROR:  missing FROM-clause entry for table "tt"
    LINE 15:         RETURNING id_user_description, tt.id_user</p>
  </blockquote>
  
  <p>How could I fix this?</p>