I have two tables of data, they are: table A and table B. I want to join the rows of table B with A under the following conditions:
If a line occurs in B and not in A, add it to A. If a row occurs more in B than occurs in A, add it to A until it occurs as often in A as in B. If I have the following two tables:
TabelaA TabelaB
2 4 1 3 2 2 2 1
2 2 2 1 2 4 1 3
4 5 2 4 2 4 1 3
1 4 2 5 2 4 1 3
2 4 1 3 5 3 2 3
I want to have the following table:
Tabela A + B
2 2 2 1
2 4 1 3
2 4 1 3
2 4 1 3
4 5 2 4
1 4 2 5
5 3 2 3
Is it possible to achieve this with an sql query?