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

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -