• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1407
  • Last Modified:

how to make sql inner join in two vb.net datatables?

I have one dataset that contains two DataTables:



DataTable1:

Customer_ID

1

2

3

4

5



the other DataTable2 returns

Customer_ID

4

5



If I would have treated this as regular queries and join them on Customer_ID
the resulting set would only contain:



Customer_ID

4

5



Is there a way to inner join the two DataTables to create a third DataTable
with the desired results. I have tried to user Relations.Add method with no
success.



Thanks
0
Ameerh24
Asked:
Ameerh24
2 Solutions
 
ReecioCommented:
I'm not sure what you're aims are, but I think you want everything from Table1 plus the information from Table2. Inner Joins pull only the common data between the two tables so I'm guessing you need an outer join.

If you want all of the rows in Table1 appended with all the rows in Table2 you'll need a left outer join, this will show all rows from Table1 but will also add the information from Table2 if there is anything there (otherwise it will be null).
Right outer join does the opposite, all from Table2 appended with data from Table1 and finally, should you need it, a full outer join gets all the information from both tables regardless if there is a common link between the two.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now