首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请教一个连接查询的有关问题

2012-03-29 
请问一个连接查询的问题有表一:date productcustomer数量3.1,A物料,客户1,13.1, A物料,客户1,4表二:(表结

请问一个连接查询的问题
有表一:
 date product customer 数量
 3.1,A物料, 客户1, 1
 3.1, A物料, 客户1, 4
表二:(表结构和表1一样)
 3.2,A物料,客户1,1
 3.2,B物料,客户1,3
连接条件:date,product,customer一样。
想得到:
 3.1 A物料, 客户1, 1, null ,null, null, null
 3.1 B物料, 客户1, 4, 3.1 B物料,客户1, 3
 null null null null 3.2 A物料 客户1, 1

请问sql该怎么写。
 


[解决办法]
select T1.*,T2.*

T1 full join T2
on T1.date = T2.date and T1.product = T2.product and T1.customer = T2.customer
[解决办法]
select T1.*,T2.*

T1 full out join T2
on T1.date = T2.date and T1.product = T2.product and T1.customer = T2.customer
[解决办法]
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

热点排行