Skip to content

Instantly share code, notes, and snippets.

@unknowntpo
Created September 2, 2022 00:46
Show Gist options
  • Save unknowntpo/e7422dbfe7e90466fd4adac25d1c8406 to your computer and use it in GitHub Desktop.
Save unknowntpo/e7422dbfe7e90466fd4adac25d1c8406 to your computer and use it in GitHub Desktop.
db_version_control.comparison_with_full_outer_join
select
temp.id as temp_id,
temp.c0 as temp_c0,
temp.c1 as temp_c1,
temp.username as temp_username,
temp.version as temp_version,
data.id as data_id,
data.c0 as data_c0,
data.c1 as data_c1,
data.version as data_version
into join_table
from temp
full outer join data on temp.c0 = data.c0 and temp.c1 = data.c1;
select * from join_table;
temp_id temp_c0 temp_c1 temp_username temp_version data_id data_c0 data_c1 data_version
3 modified old1 Eric 2 NULL NULL NULL NULL
5 new0 new1 Kevin 2 NULL NULL NULL NULL
NULL NULL NULL NULL NULL 1 old0 old1 1
4 old2 old2 Eric 2 2 old2 old2 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment