select code1 ,code 2,code 3,money
from 表二 b cross join 表三 c cross join 表四 d
left outer join 表一 a on a.code1=b.code1 and a.code2=c.code2 and a.code3=d.code3
from 表二 b cross join 表三 c cross join 表四 d
left outer join 表一 a on a.code1=b.code1 and a.code2=c.code2 and a.code3=d.code3
解决方案 »
- 查找ip所在的网段问题
- 100分求SQLSERVER快照复制完成后如何自动删除快照文件
- sql server 记录数据格式
- 求一SQL语句
- 亲情大奉献 一个不错的计算机图书下载网站
- 执行带where 的update的时候,请求的共享锁或排他锁锁定的资源范围是什么?
- SQL Server 6.5的数据能升到SQL Server 2000的吗?
- 除了游标还有什么?数据记录遍历,帮帮小弟吧
- 如过表已经建好,另加了一个字段后想改变它的位置,该如何实现?
- 这个select语句怎样写?使用group by 分组后怎样才能统计出分了几组??87放送!!
- 安装sqlserver2000时选择的是:本地帐户,装好后如何把sqlserver的帐户改为域帐户,或在sqlserver里添加一个域帐户?
- xp上安装的sql数据客户端出问题怎么回事
b.code1 ,
c.code2,
d.code3,
a.money
from
表二 b cross join
表三 c cross join
表四 d left outer join
表一 a
on a.code1=b.code1
and a.code2=c.code2
and a.code3=d.code3
order by b.code1,c.code2,d.code3
(code1 int,code2 int,code3 int,money int)
insert @t1 values (1,5,11,100)declare @t2 table
(code1 int,name varchar(20))
insert @t2 values (1,'a')
insert @t2 values (2,'b')declare @t3 table
(code2 int,name varchar(20))
insert @t3 values (5,'m')
insert @t3 values (6,'n')declare @t4 table
(code3 int,name varchar(20))
insert @t4 values (11,'a1')
insert @t4 values (12,'a2')
insert @t4 values (13,'a3')
select a.code1,b.code2,c.code3,d.money
from
@t2 a cross join @t3 b cross join @t4 c
left join @t1 d on a.code1=d.code1 and
b.code2=d.code2 and c.code3=d.code3
code1 code2 code3 money
----------- ----------- ----------- -----------
1 5 11 100
1 6 11 NULL
1 5 12 NULL
1 6 12 NULL
1 5 13 NULL
1 6 13 NULL
2 5 11 NULL
2 6 11 NULL
2 5 12 NULL
2 6 12 NULL
2 5 13 NULL
2 6 13 NULL(所影响的行数为 12 行)
a.code1,
b.code2,
c.code3,
d.money
from
表二 a
cross join
表三 b
cross join
表四 c
left join
表一 d
on
a.code1=d.code1
and
b.code2=d.code2
and
c.code3=d.code3
order by
a.code1,b.code2,c.code3
SELECT B.日計日付,B.駅コード,B.窓口コード,A.定期定期外区分, A.通常後払区分,A.券種コード ,
B.枚数,B.払戻額,B.表示番号,B.データ発生区分,B.自社コード,B.サイバネコード,
B.エラーフラグ,B.エラー内容,B.更新者ID,B.更新日時
FROM
( SELECT 定期定期外区分, 通常後払区分, 券種コード
FROM M_DM定期定期外区分 ,M_DM通常後払区分 , M_DM券種
WHERE 定期定期外区分 = '1' and 券種コード <> '4') A Left outer join 駅収管理手作業払戻データ B
ON A.定期定期外区分 = B.定期定期外区分 and
A.通常後払区分 = B.通常後払区分 and
A.券種コード = B.券種コード
基本思路就是把表2,3,4先全结合起来,再左连接表1,实现所有组合全部表示
风云给的答复看得我眼花了,基本上和别看资料,红尘联委的就可以解决这个问题了。我的代码由于还要过滤几个特殊条件,写出来给大家看看而已^_^
现在结账,谢谢大家了