How to find unique elements between two different datatable and then store the result in different data table

Hi,

I have two different data table.
1st table looks like:
Account Num
123456 234567

2nd table looks like

image

Now I want to find the unique element in between those two datable and want to store the result in another datatable.

Thanks in advance

Hi @ssinha1 ,

check this once

What is “unique element” in your example?
345678?

What if 1ts table contains also 456789?
Would it be also “unique element” to be stored?

Cheers

Hi @ssinha1

Use Join datatable with inner join as below

Hope it helps!!

yes, and in my case 345678 is the unique element and want to store this value in different dt.

Does it mean you need full outer join like in the picture?
image

So you want to make left join excluding right?
image

A = table2
B = table1

In that case use the following code

list = (From d2 In dt2.AsEnumerable
Where  Not dt1.AsEnumerable.Any(Function (d1) d1(0).toString.Trim.Equals(d2(0).toString.Trim))
Select r=d2).toList

yeah this can also work.

@ssinha1

Try my solution with condition !=

Hope it helps!!

And indeed the solution proposed by @Davuluri_Manikumar gives the same result and is even easier… :slight_smile:

Cheers