title: How to insert and then update returned Id from insert query as returning id in a single command in postgres?
body: <p>I have a demo table </p>
  
  <pre><code>CREATE TABLE items (
    id SERIAL primary key,
    user_id integer,
    name character varying,
    created timestamp with time zone default now()
  );
  </code></pre>
  
  <p>And I want a single query to run and first insert data, then return primary key using returning id and then update the same table with the returned id.</p>
  
  <pre><code>INSERT INTO items (name) values ('pen') RETURNING id as idd 
  update items set user_id=(select idd) where id=(select idd)
  </code></pre>
  
  <p>but the above command doesn't work and throws syntax error.
  Any help will be appriciated.</p>