创建一个新的datatable c
用foreaech 分别取出 ab中的每一行 添加到c
能在数据库那边处理么?比如用group by
1、在数据库对其 A、B表进行分组统计,再新建C表,把筛选后的数据插入C表;
2、可以采用对象模型,对其A、B表结构类型,可以采用Linq合并
dataTable1.Merge(dataTable2);
select name,sum(count) from
(
select t.name , t.count from a t where name in (select name from b)
union all
select name , count from b
union all
select name ,count from a where name not in (select name from b)
) m
group by m.name
select name,sum(count) from
(
select t.name , t.count from a t where name in (select name from b)
union all
select name , count from b
union all
select name ,count from a where name not in (select name from b)
) m
group by m.name