Foxtable(狐表)用户栏目专家坐堂 → 提取两表不重复“年月”到另一表中


  共有2097人关注过本帖树形打印复制链接

主题:提取两表不重复“年月”到另一表中

帅哥哟,离线,有人找我吗?
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107301 积分:545766 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/3/29 23:13:00 [显示全部帖子]

Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.CommandText = "SELECT DISTINCT 年月 From (select year(第一列)+'-' + month(第一列) as 年月 from {表A}  union select year(第二列)+'-' + month(第二列) as 年月 from {表B}) as a"
dt = cmd.ExecuteReader()
For Each dr As DataRow In dt.datarows
    Dim r As Row = Tables("表C").addnew
    r("第三列") = dr("年月")
Next

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107301 积分:545766 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/3/30 8:48:00 [显示全部帖子]

cmd.CommandText = "SELECT DISTINCT 年月 From (select cstr(year(第一列))+'-' + cstr(month(第一列)) as 年月 from {表A} where 第一列 is not null  union select cstr(year(第二列)) +'-' + cstr(month(第二列)) as 年月 from {表B} where 列 is not null) as a"

 回到顶部