Check this:
Dim table1 As DataTable = New DataTable()
table1.Columns.Add(New DataColumn("Drug_no", Type.GetType("System.Int32")))
table1.Columns.Add(New DataColumn("DrugName", Type.GetType("System.String")))
table1.Rows.Add(New Object(){1, "A"})
table1.Rows.Add(New Object(){2, "B"})
table1.Rows.Add(New Object(){3, "C"})
table1.Rows.Add(New Object(){4, "D"})
Dim table2 As DataTable = New DataTable()
table2.Columns.Add(New DataColumn("Drug_no", Type.GetType("System.Int32")))
table2.Columns.Add(New DataColumn("Substance", Type.GetType("System.String")))
table2.Rows.Add(New Object(){1, "Num"})
table2.Rows.Add(New Object(){1, "Feb"})
table2.Rows.Add(New Object(){2, "tell"})
table2.Rows.Add(New Object(){2, "tak"})
Dim result = table1.AsEnumerable() _
.GroupJoin(table2.AsEnumerable(), _
Function(t1) t1.Field(Of Integer)("Drug_no"),
Function(t2) t2.Field(Of Integer)("Drug_no"),
Function(a, b) New With { _
.DrugNo = a.Field(Of Integer)("Drug_no"), _
.DrugName =a.Field(Of String)("DrugName"), _
.Substances = String.Join(",", b.Select(Function(x) x.Field(Of String)("Substance")).ToArray())})
Result:
DrugNo DrugName Substances
1 A Num,Feb
2 B tell,tak
3 C
4 D
For further information please, see:
Group Join Clause (Visual Basic)[
^]
101 Linq samples (lambda style): GroupJoin[
^]