Actually my question is basically the same as here but I need to insert values from a nested query into an existing table and I'am not that familiar with sql as to know how to incorporate the setval part into my query:
insert into table_a
select * 
from table_b 
where val_1 IN (select "val_1" from table_c where "val_2" is null)
returns
ERROR:  duplicate key value violates unique constraint "table_a_pkey"
DETAIL: Key (qid)=(470971) already exists.
Now I know I could do a workaround with drop column and autgenerate as described here but there must be a more elegant way. I am using Postgresql/Postgis 2.4 btw.
