title: PostgreSQL - Update rows in table with generate_series()
body: <p>I have the following table:</p>
  
  <pre><code>create table test(
      id              serial primary key,
      firstname       varchar(32),
      lastname        varchar(64),
      id_desc         char(8)
  );
  </code></pre>
  
  <p>I need to insert 100 rows of data. Getting the names is no problem - I have two tables one containing ten rows of first names and the other containing ten last names. By doing a insert - select query with a cross join I am able to get 100 rows of data (10x10 cross join). </p>
  
  <p>id_desc contains of eight characters (fixed size is mandatory). It always starts with the same pattern (e.g. abcde) followed by 001, 002 etc. up to 999. I have tried to achieve this with the following statement:</p>
  
  <pre><code>update test set id_desc = 'abcde' || num.id
      from (select * from generate_series(1, 100) as id) as num
          where num.id = (select id from test where id = num.id);
  </code></pre>
  
  <p>The statement executes but affects zero rows. I know that the where-clause probably does not make much sense; I have been trying to finally get this to work and just started trying a couple of things. Didn't want to omit it though when posting here because I know it is definitely required.</p>