C# .NET - Left join between two DataTables - Asked By Anandh Ramanujam on 28-Dec-10 08:50 AM

Hi,

I am having two datatables having a common column.

I want to join two datatables like left outer join in sql.

How can we do that.. Can u pls help...

Thanks.
Daivagna Nanavati replied to Anandh Ramanujam on 28-Dec-10 09:38 AM
Hi Anandh

say suppose you are having following type of table structure

Emp
--------------
Id Name DeptID

and another table might be like following

Department
--------------
Id Name

now her you can do like following

SELECT
    a.Name,b.Name
FROM
    emp a
LEFT OUTER JOIN
    dept b
ON
    a.DeptId = b.Id

in this way you would be able to join them, here advantage of left join would be even if some department is missing in emp table still it will get the data of all employees

let me know

Thanks


Anandh Ramanujam replied to Daivagna Nanavati on 29-Dec-10 10:01 AM
Thanks for your reply...

But I want it to do with DataTables not in Sql....

Thanks