Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共21 条记录, 每页显示 10 条, 页签: [1] [2][3]
[浏览完整版]

标题:合并数据操作问题

1楼
lin98 发表于:2023/8/24 10:31:00
表A的字段:单号,料号,品名,数量,日期,审核
表B的字段:单号,料号,品名,数量,日期,审核,客户


注:
2.合并后在,单号,料号,品名,在同一行


'Dim cmd As New SQ-LCommand
'Dim dt As DataTable
'Dim sCols() As String = {"单号", "料号", "品名", "数量", "日期"}
'Dim dCols() As String = {"单号", "料号", "品名", "表A数量", "日期"}
'cmd.C'"
'cmd.CommandText = "SELEC-T * From {表A}WHERE 审核 = '未审核"
'dt = cmd.ExecuteReader()
'For Each dr As DataRow In dt.DataRows
'    Dim nr As DataRow = DataTables("员工").AddNew()
'    For i As Integer = 0 To sCols.Length - 1
'        nr(dCols(i)) = dr(sCols(i))
'    Next
'Next
[此贴子已经被作者于2023/8/25 16:51:23编辑过]
2楼
有点蓝 发表于:2023/8/24 10:49:00
如果是SqlServer,直接使用SQL生成表D参考

sel
ect a.单号,a.料号,a.品名,a.数量 as 表A数量,a.日期 as 表A日期,表B数量,表C数量,a.审核 from 表A as a inner join ( select 单号,料号,品名,sum(数量) as 表B数量 from 表B group by 单号,料号,品名) as b on a.单号=b.单号 and a.料号=b.料号 and a.品名=b.品名 inner join ( select 单号,料号,品名,sum(数量) as 表C数量 from 表C group by 单号,料号,品名) as c on a.单号=c.单号 and a.料号=c.料号 and a.品名=c.品名 
3楼
lin98 发表于:2023/8/24 11:42:00
Dim cmd As New SQ-LCommand
cmd.C'
Dim dt As DataTable
cmd.CommandText = select a.单号,a.料号,a.品名,a.数量 as 表A数量,a.日期 as 表A日期,表B数量,表C数量,a.审核 from 表A as a inner join ( select 单号,料号,品名,sum(数量) as 表B数量 from 表B group by 单号,料号,品名) as b on a.单号=b.单号 and a.料号=b.料号 and a.品名=b.品名 inner join ( select 单号,料号,品名,sum(数量) as 表C数量 from 表C group by 单号,料号,品名) as c on a.单号=c.单号 and a.料号=c.料号 and a.品名=c.品名 
Tables("表D").DataSource = cmd.ExecuteReader()
执行报错
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2022.8.18.1
错误所在事件:
详细错误信息:
SELEC-T 子句中包含一个保留字、拼写错误或丢失的参数,或标点符号不正确
[此贴子已经被作者于2023/8/24 11:42:10编辑过]
4楼
有点蓝 发表于:2023/8/24 11:45:00
各种中文的符号改为英文符号,如逗号等改为英文逗号。

另外这种语法适合SqlServer,其它数据库的多表关联用法请自行百度
5楼
lin98 发表于:2023/8/24 11:59:00
现数据源是ACCESS,还有一个,以表A:单号,料号,品名,数量,日期,审核=未审核,审核=未审核,要加在哪位置?
6楼
有点蓝 发表于:2023/8/24 14:24:00
加到最后面
.........=c.料号 and a.品名=c.品名  where a.审核='未审核'
7楼
lin98 发表于:2023/8/24 15:10:00
Dim cmd As New SQ-LCommand
cmd.C'
Dim dt As DataTable
cmd.CommandText = select a.单号,a.料号,a.品名,a.数量 as 表A数量,a.日期 as 表A日期,表B数量,表C数量,a.审核 from 表A as a inner join ( select 单号,料号,品名,sum(数量) as 表B数量 from 表B group by 单号,料号,品名) as b on a.单号=b.单号 and a.料号=b.料号 and a.品名=b.品名 inner join ( select 单号,料号,品名,sum(数量) as 表C数量 from 表C group by 单号,料号,品名) as c on a.单号=c.单号 and a.料号=c.料号 and a.品名=c.品名 where a.审核='未审核'
msgbox(cmd.CommandText) '
Tables("表D").DataSource = cmd.ExecuteReader()'
MsgBox(1)'

执行后,没报错,也没有数据显示,调试也没显示内容,如何解决?据源是ACCESS
8楼
有点蓝 发表于:2023/8/24 15:12:00
https://www.baidu.com/baidu?ie=UTF-8&word=access%20%E5%A4%9A%E8%A1%A8%E5%85%B3%E8%81%94
9楼
lin98 发表于:2023/8/24 15:27:00
老师,找不到问题,还是没有数据显示,如何解决?
10楼
有点蓝 发表于:2023/8/24 16:23:00
cmd.CommandText = select a.单号,a.料号,a.品名,a.数量 as 表A数量,a.日期 as 表A日期,表B数量,表C数量,a.审核 from (表A as a inner join ( select 单号,料号,品名,sum(数量) as 表B数量 from 表B group by 单号,料号,品名) as b on a.单号=b.单号 and a.料号=b.料号 and a.品名=b.品名) inner join ( select 单号,料号,品名,sum(数量) as 表C数量 from 表C group by 单号,料号,品名) as c on a.单号=c.单号 and a.料号=c.料号 and a.品名=c.品名 where a.审核='未审核'
共21 条记录, 每页显示 10 条, 页签: [1] [2][3]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .06543 s, 2 queries.