以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- SQL多表查询 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=69114) |
-- 作者:雁过不留痕8 -- 发布时间:2015/5/30 16:45:00 -- SQL多表查询 Dim cmd As New SQLCommand Dim dt As DataTable cmd.CommandTimeOut=60 cmd.C If(t2.text="")Then cmd.CommandText = "SELECT count(*) F rom " & "{" & "装配线条码追溯表" & yearstring & monthstring & "} WHERE " & "[JH]=\'" & jhhString & "\'" a=cmd.ExecuteScalar cmd.CommandText = "SELECT count(*) F rom " & "{" & "装配线条码追溯表" & yearstringf & monthstringf & "} WHERE " & "[JH]=\'" & jhhString & "\'" t3.text=cmd.ExecuteScalar t3.text=a+t3.text
|
-- 作者:雁过不留痕8 -- 发布时间:2015/5/30 16:46:00 -- 要实现上述功能,即删选出两个表中符合条件的行数和 为什么union all不能实现呢,是我的代码有问题吗 |
-- 作者:雁过不留痕8 -- 发布时间:2015/5/30 16:47:00 -- 抱歉,代码粘不上来,代码就是两个select语句之间加了个union all |
-- 作者:Bin -- 发布时间:2015/5/30 16:58:00 -- 复制到记事本里发上来吧 |
-- 作者:雁过不留痕8 -- 发布时间:2015/5/30 17:03:00 -- cmd.CommandText = "SELECT count(*) F rom " & "{" & "装配线条码追溯表" & yearstring & monthstring & "} WHERE " & "[JH]=\'" & jhhString & "\' union all |
-- 作者:雁过不留痕8 -- 发布时间:2015/5/30 17:05:00 -- cmd.CommandText = "SELECT count(*) F rom " & "{" & "装配线条码追溯表" & yearstring & monthstring & "} WHERE " & "[JH]=\'" & jhhString & "\' union all S ELECT count(*) F rom " & "{" & "装配线条码追溯表" & yearstring & monthstring & "} WHERE " & "[JH]=\'" & jhhString & "\' |
-- 作者:雁过不留痕8 -- 发布时间:2015/5/30 17:05:00 -- 终于粘上来了 |
-- 作者:雁过不留痕8 -- 发布时间:2015/5/30 17:06:00 -- cmd.CommandText = "SELECT count(*) F rom " & "{" & "装配线条码追溯表" & yearstring & monthstring & "} WHERE " & "[JH]=\'" & jhhString & "\' union all S ELECT count(*) F rom " & "{" & "装配线条码追溯表" & yearstring & monthstring & "} WHERE " & "[JH]=\'" & jhhString & "\'" |
-- 作者:雁过不留痕8 -- 发布时间:2015/5/30 17:06:00 -- cmd.CommandText = "SELECT count(*) F rom " & "{" & "装配线条码追溯表" & yearstring & monthstring & "} WHERE " & "[JH]=\'" & jhhString & "\' union all S ELECT count(*) F rom " & "{" & "装配线条码追溯表" & yearstringf & monthstringf & "} WHERE " & "[JH]=\'" & jhhString & "\'" |
-- 作者:雁过不留痕8 -- 发布时间:2015/5/30 17:07:00 -- 两个月表查询符合条件的行数和 |