How to unify two tables with repeated primary keys?

Asked

Viewed 66 times

0

I have two tables that we need to unify in one, in a complete way: Consider everything there is in the first, see if it matches with the second and what does not hit or repeat, include in the lines of the end.

Note that key 2 is repeated in the second table, therefore, a procv would not solve in the case of 2 or more incidences. Key 5 has no incidence in the first table. In these cases, they were inserted at the end of the third table.

Following example:

	Tabela 1									
										
A	B	C	D	E	F					
1	Brasil	Carro	Honda	Fit	100					
2	Chile	Carro	Honda	CRV	200					
3	Russia	Moto	yamaha	Crosser	150					
4	Russia	Carro	Volvo	v40	300					
										
	Tabela 2									
										
U	V	X	Y	W	Z					
1	Brasil	P	-	-	100					
2	Chile	-	4rodas	-	100					
2	Uruguai	G	4rodas	-	100					
5	EUA	G	8rodas	Transporte	400					
										
	Tabela 3 unificada
							
A	B	C	D	E	F	V	X	Y	W	Z
1	Brasil	Carro	Honda	Fit	100	Brasil	P	-	-	100
2	Chile	Carro	Honda	CRV	200	Chile	-	4rodas	-	100
3	Russia	Moto	yamaha	Crosser	150					
4	Russia	Carro	Volvo	v40	300					
5	EUA					EUA	G	8rodas	Transporte	400
2						Uruguai	G	4rodas	-	100

Could you help me?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.