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

html - How to custom Bootstrap grid height? -

javascript - pass values from mssql to views in node -

javascript - Understanding ExtJS Framework Syntax -