sql - union table, change serial primary key, postgresql -


postgresql:

i have 2 tables 'abc' , 'xyz' in postgresql. both tables have same 'id' columns type 'serial primary key;'. abc table id column values 1,2,3 , xyz id column containing same values 1,2,3,4 want union both tables 'union all' constraint. want change 'xyz' id column values next value of 'abc' id column last value 1,2,3,4,5,6,7

select id abc union select id xyz  |id|  1  2  3  1  2  3  4  wanted resuls |id|  1  2  3  4  5  6  7 

better - @caiusjard should you

select id abc  union select x.id + a.maxid xyz x,  (select max(id) maxid abc) order id 

Comments

Popular posts from this blog

Ansible warning on jinja2 braces on when -

Parsing a protocol message from Go by Java -

javascript - Replicate keyboard event with html button -