Preciso unir dados DISTINTOS de duas tabelas

Ola comunidade!

Preciso unir IDs diferentes de duas tabelas.

Por exemplo: tenho a tabela1 que contem alguns IDs que também estão na tabela2, porem eu não quero os IDs que ambas possuem. Eu preciso criar uma terceira tabela que retorne os IDs unicos, tanto de uma quanto de outra.

Preciso fazer a comparação entre as tabelas verificar quias IDs se repetem em ambas e retornar apenas os que NÃO se repetem, ou seja, diferentes.

Já tentei utilizar a atividade JOIN com o operador logico != mas não atinge ao resultado esperado.

Obrigada.

We can do the following:
Join DataTable - Full Join - out:dtJoin

Afterwards we find the IDs only present in table (e.g. Left Table OR right Table) when:

  • check if one the two join column values is null/empty
2 Likes

Hi @devrpa746
Give a try to this.
Keep only ID column in the both input table and use the following query.
dt_output1=if(dt_input1.AsEnumerable.Except(dt_input2.AsEnumerable,system.data.DataRowComparer.Default).any,dt_input1.AsEnumerable.Except(dt_input2.AsEnumerable,system.data.DataRowComparer.Default).CopyToDataTable,dt_input1.Clone) //Returns ID available only in the first table.

dt_output2=if(dt_input2.AsEnumerable.Except(dt_input1.AsEnumerable,system.data.DataRowComparer.Default).any,dt_input2.AsEnumerable.Except(dt_input1.AsEnumerable,system.data.DataRowComparer.Default).CopyToDataTable,dt_input2.Clone) //Returns ID available only in the second table.

Then merge two output data tables.
Sample workflow
Join.xaml (9.6 KB)

Hope this helps.

2 Likes